Ever wanted to get the full Office 365 profiles of users in a SharePoint Person or Group column? I’ve had a couple of requests for this recently and also helped someone on the Power Apps forums with the same requirement. So figured I’d put this quick fire article together to show the solution.
Table of Contents
ToggleRequirement / Setup
The ask in slightly more detail was to retrieve the relevant Person entries for a selected item. Then, create a separate collection with the relevant users and their full user profiles.
To test out a proposed method, first I need a SharePoint list that includes a Person or Group column. It will need to be set to allow single or multiple persons:
In SharePoint, user information is limited to just six pieces of information; claims, department, display name, email, job title & profile image. Here’s an example of each of the outputs:
But what if we want additional information like line manager, city, country or phone number? Typically our Active Directory profiles will be far richer in information.
Power Apps logic
In Power Apps, ensure you have added a connection to your SharePoint list, as well as the Office 365 Users connector:
Let’s visualise the records in a gallery. We can add a vertical gallery to our canvas app and set the Items property to the SharePoint list:
Bonus tip!
Person or group columns effectively store data as a nested table. To visualise all outputs in a gallery isn’t as simple as adding a label and referencing ThisItem. We need to join the relevant pieces of information together. In my example, I want to show the display name for each person in the column, for each entry. We can do this with the Concat function:
// From character column, get each Display Name attribute,
// Then append with a comma & space
Concat(
ThisItem.Character,
DisplayName,
", "
)
Here we can see the result for each of our three items:
The solution
As a reminder, the requirement is to select a gallery item and create a new collection. The collection will take each person listed in the Person or Group column in the list item and get their full AD profile.
Either on the arrow in the gallery, or on the gallery itself, we’ll need the OnSelect property. I’ll make a new collection called colCharacterProfiles. In the OnSelect property I’ll need the following code:
// Empty collection ready for a new set of entries
Clear(colCharacterProfiles);
// Create collection. Use email field as reference for O365 Users connector
Collect(
colCharacterProfiles,
ForAll(
ThisItem.Character,
Office365Users.UserProfileV2(Email)
)
)
We now have each user but with access to their full profile details:
If you don’t have a gallery to directly interact with, you can retrieve the required record via a lookup. This involves storing the information temporarily using the With function, then performing the same logic to built the colCharacterProfiles collection.
// Empty collection ready for a new set of entries
Clear(colCharacterProfiles);
// Get list item using ID. Character is the column we need, Email is the property we need from it
With(
{
tvPersonOrGroupOutput: LookUp(
'Star Wars Characters',
ID = 3,
Character
).Email
},
// Create collection. Use email field as reference for O365 Users connector
Collect(
colCharacterProfiles,
ForAll(
tvPersonOrGroupOutput,
Office365Users.UserProfileV2(Email)
)
)
)
There we have it, a simple solution to get full profile information for all users stated in a SharePoint Person or Group column!
Thanks for reading. If you liked this article and want to receive more helpful tips about Power Platform every week, don’t forget to subscribe or follow me on socials 😊