Recently I was responding to the PowerApps forum and see the requirement and decided to write a blog about it. So what is that?
Requirement
Display Person names in a combo box. The source is Share Point and Multi-select person or group field. The requirement is to maintain the Person or Group Type which to keep all properties like (DisplayName, Email, Department, Claims, and Job Title).
SharePoint-MultiSelect-Person
Expected Output (Combo Box)
Display Distinct Person from this MultiPeople column from Sharepoint
Person column is always unique and Multi-Select involves more challenge with it. Initially, I thought just to ungroup it but Distinct and Sort won’t work until we do some tricks.
Combo Box
Set the items property of the Combo Box to
With({Items: Ungroup(ForAll(SPList,MultiplePeopleColumn),”Value”),
DistinctEmail:Distinct(Ungroup(ForAll(SPList,MultiplePeopleColumn),”Value”),Email)},
Sort(
ForAll(DistinctEmail,First(Filter(Items,Email=Result))),
DisplayName
)
)
References
Conclusion
We are able to display the Person or group in the combo box using With function and maintain the Person Type.
This entry was really helpful. One note about an addition I had to make to get it to work for me. It looks like it ends up displaying whatever might be set up in the system as the first column of data, in our case it was the Claims column. I had to add a .DisplayName at the end and then it started showing the DisplayName in the dropdown for me.
Thanks Kim for the insight.
Thanks so much! My use case was a single person selection – so I had to remove the Ungroup( ) function. but – then it works!
With({Items: ForAll(‘License Tracking List’,Employee),
DistinctEmail:Distinct(ForAll(‘License Tracking List’,Employee),Email)}
,
Sort(
ForAll(DistinctEmail,First(Filter(Items,Email=Result))),
DisplayName
)
)
I am trying this and is not working , guess i am missing something, what is value ?
With({Items: ForAll(‘images Trials’;Rep);
DistinctEmail:Distinct(ForAll(‘images Trials’; Rep); Email)}
;
Sort(
ForAll(DistinctEmail; First(Filter(Items; Email=Result)));
DisplayName
)
)
According to the MS documentation, the output column of the Distinct function is “Value”: https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-distinct Changing the “Result” to “Value” part of the Distinct function made it work for me.
what about Multi-select people picker? How to set defaultselectedItems property for this field when we are looking to bind data?