This is an interesting scenario and infact turned out to be tougher than I thought. Let’s look at the requirement first.
I have a List in SharePoint which a Person column – Approver1. Screenshot below for reference.
All I need is to show the values from Approver1 field in a combobox inside canvas app. Seems like a fairly simple requirement.
I insert a combobox control on my screen in Canvas app. Few basic things I do. First set the Items property of the combobox to the following formula. ‘Sample List’ is the name of my SharePoint list.
Choices('Sample List'.Approver1)
And then set the Layout of the combobox to Person.
And I thought that was it. Unfortunately it didn’t work. My requirement was to allow the users to select an value from the list of available options. Below is the observed behavior.
Surprisingly the combobox is allowing to select any user available irrespective of whether they are present in the Approver1 field of the list. I am able to select “MOD Administrator” and “Everyone except external users” even though they are not in Approver1 field.
Since it didn’t work, I decided to change the Items formula. I set it to the below formula. The App checker does not show any error.
Now when I run the app, it seems like it show three items. But I could not see any value in there. So this does not solve the purpose too.
Searched the heck out of google and could not come with a proper solution. Finally after a long drawn struggle, this is what I did.
OnVisible of the screen, I created a collection to store the list of values in Approver1 field. You can do it in other places as well like OnStart of App or wherever you find it OK.
Now set the Items property of the combobox to Approver1List collection. And then we start seeing as expected.
But we still have a problem. Observe that items are duplicated in the list. John C appears twice (highlighted in yellow).
For that, change the Items formula to below.
GroupBy(Approver1List, "DisplayName", "Email", "Picture", "Claims", "grpApprovers")
And now everything works as expected.
Before I end this blog, a very important thing to note here – This procedure described here will only work for if “Allow multiple selections” is unchecked.
Hope this helped! You will also like the below posts.
Debajit Dutta
Business Solutions MVP
Discover more from Debajit's Power Apps & Dynamics 365 Blog
Subscribe to get the latest posts sent to your email.