PowerApps: Convert O365 User to SharePoint People

In this blog, we will discuss how to convert Office 365 users to SharePoint People.

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, display users who don’t have a Zipcode/Postal code with Search.

Background

In PowerApps, to display users/peoples 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 record that the previously saved. Our expectation is the people column should 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 able to convert one object type to another object type in Powerapps. In our example, PowerApps used O365 User, but data was stored in the form of Sharepoint People.

Enjoy learning!

Leave a Reply

Your email address will not be published.