PowerApps: Convert O365 User to SharePoint People

This blog will discuss converting Office 365 users in PowerApps to SharePoint People type.

Requirement

In PowerApps, Businesses often would like to display users from the O365 list with some filter instead of the SharePoint People List. For Example, when using SharePoint as a data source, show users who don’t have a Zip code/Postal code with Search.

Background

In PowerApps, to display users/people from SharePoint, set the Items property of the combo box to

Choices([@SPListName].PeopleColumnName)

O365 Users

In this example, We will display the users who don’t have postal codes. To display Office365 users with Search and predefined filters. Set the items property of the combo box to

Filter(Office365Users.SearchUserV2(
{ searchTerm: AssigneToO365Users.SearchText, top: 10 }
).value,
!IsBlank(PostalCode)
)

AssigneToO365Users – Combo Box Name

Result will be

 

Conversion

What is conversion, then?

Now combo box displays the O365 user object, but SharePoint has a people column with a different object. Both objects’ schema/structure won’t match. So we have to convert the O365 object to SharePoint People type.

Need to set the Update property of the Card (Not Control). Refer to the below image.

Now run the application form and saves it successfully to SharePoint.

Edit Record

Now select the item from the gallery to edit the previously saved record. We expect the people column to display the saved value (people/user), but it won’t.

For this, set the DefaultSelectedItems property of the combo box to

With(
{User: Office365Users.UserProfileV2(BrowseGallery1.Selected.’Assigned to’.Email)},
{
Claims: “i:0#.f|membership|” & User.mail,
Department: “”,
DisplayName: User.displayName,
Email: User.mail,
JobTitle: “”,
Picture: “”
}
)

Conclusion

We can convert one object type to another object type in PowerApps. PowerApps used O365 User in our example, but the user is stored as SharePoint People.

Enjoy learning!

One comment

  1. Hi this works fine, but ut the combo box is blank/no selected I get an error when I submit the form.

Leave a Reply

Your email address will not be published. Required fields are marked *