cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AIUYM19
Helper V
Helper V

How to list names from SharePoint people picker in combo box dropdown

I have a combo box that should display the names from a people picker field in a SharePoint list. The field in SharePoint is configured to allow multiple selections. How do I make the combo box dropdown display a list of all the contact names that appear in that field? I tried

Items = Choices([@'Action Items'].Contacts).DisplayName

but no dropdown appeared at all when I clicked the combo box arrow. Then, I tried

Items = 'Action Items'.Contacts

 and a list did show up in a dropdown, but all the entries were blank. I have the DefaultSelectedItems property set to User().FullName, and that is working. I want a gallery on that screen to be filtered based on the names selected in the combo box. The gallery filter should show all items that have any of the selected names.

1 ACCEPTED SOLUTION

Accepted Solutions
AIUYM19
Helper V
Helper V

OK! I've finally come up with a really messy and far too complicated way to make this work! Here's what I did...

I wanted the drop-down of a combo box to list all the names that appeared in the Contacts column in a SharePoint list. The Contacts column is a multi-selection person/group column set to allow only people. Because it's multi-select, this results in a table (MS-speak for "array") in the Contacts field, instead of an object, and the Items property of a combo box can't handle a table (array). For increased performance, I loaded the items from the SharePoint list into a collection, and then built a second collection to house each of the person objects that appeared in the Contacts column.

First, I used the Ungroup function to basically rip each person object out of the Contacts column, and create a new record for each. I used the ShowColumns function on the result to limit the number of columns that would be in the new collection. Finally, I used the Collect function to create the new collection, and then applied the resultant collection to all items of the first collection using the ForAll function. Here's the OnVisible property of the screen...

Refresh('Action Items');
ClearCollect(MasterList, 'Action Items');
ForAll(MasterList,
    Collect(MasterContacts,
        ShowColumns(
            Ungroup(MasterList, "Contacts"),
            "ID",
            "Claims",
            "DisplayName",
            "Email"
        )
    )
);

 Back to the combo box in question. In the Items property, I can now enter the new MasterContacts collection, making sure to remove duplicates and sort appropriately.

Items property of combo box control...

Sort(
    Distinct(
        MasterContacts,
        DisplayName
    ),
    Result,
    Ascending
)

Since the Items property now refers to a single-column table of text values (one-dimensional String array), the Item property of the combo box can use it, and all the names appear in the drop-down once and only once, and in alphabetical order. Additionally, the SelectedText.Value property of the combo box now allows direct comparison to the DisplayName property of the person object in all other controls on the screen.

View solution in original post

7 REPLIES 7
rohsh354
Community Support
Community Support

Hello,

 

If you want to use Combo box as a people picker, choose the Person template from the Layout settings in the Data pane and configure the related data properties to be shown for the person. More details on the article below. User should type some text to return search results in the combo box. 

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/controls/control-combo-box

 

Based on my research, drop downs does not work as expected for People picker fields.

As you can see, we get warning when selecting a people picker field in drop down control:

Screen1.png

 

 

@rohsh354 

Hi, Rohit.

If the combobox or dropdown list aren't very good as people pickers, what method would you suggest? I don't necessarily have to use a combobox; it just seemed like the most intuitive way to let users choose from a menu or enter their own value. The end goal is to filter a gallery such that all items with at least one of the selected people are shown.

@rohsh354 

I've been working at this for the last few days, and I still can't find a way to have the dropdown list all names from the SharePoint field. I can choose the "People" layout, but I can't choose DisplayName (or any other field from the People column) for one of the data points. The Contacts field doesn't even show up as an option in the data list. What if I did something like this?

Sort(
    Distinct(
        'Action Items',
        Contacts.DisplayName
    ),
    Result,
    Ascending
)

The problem is that Contacts is an object with multiple people objects in it, so Contacts.DisplayName doesn't really mean anything. It would be Contacts.[some object identifier].DisplayName, right?

If the Contacts field is a single person only, then this works fine. It the Contacts field is configured to hold multiple entries, then this fails.

I still can't figure this out. The OnVisible property of a screen takes a SharePoint list, and essentially clones it into a collection called MasterList (I've found this increases responsiveness of the Power App). One of the columns in MasterList (and in SharePoint) is called Contacts. In SharePoint, this is a people picker column that allows multiple selections. In MasterList, this ends up as a column of table values. The table value contains the person (or "claims") objects that represent the users selected in SharePoint. So, if two people are selected in SharePoint, then the corresponding MasterList.Contacts value for that SharePoint entry will be a table containing two people objects. I am trying to set up a combobox such that the dropdown lists the DisplayName property of all people objects from the entire Contacts column (keep in-mind that when referring to MasterList.Contacts, we are in effect referring to a table of tables).

Problem: PowerApps will not let me enter MasterList.Contacts.DisplayName into the Items property of the combobox, because Contacts is a table of tables and not an object. I've also tried Choices(MasterList.Contacts).DisplayName, but I get the same result; Power Apps will either refuse to let me enter that, or it will simply show nothing in the dropdown. How can I get Power Apps to list the DisplayName value for each entry in the table for all tables in that MasterList column. Curiously, Power Apps will not allow me to set the IsSearchable property to true; it changes it back to false as soon as I click away.

I'm 90% certain at this point that I'm going about this entirely the wrong way. Any push in the right direction would be most appreciated.

Have you tried setting a variable to retrieve the data from sharepoint and building from there, either as a global on the App OnStart property or a Collection for the screen Onvisible property?

AIUYM19
Helper V
Helper V

OK! I've finally come up with a really messy and far too complicated way to make this work! Here's what I did...

I wanted the drop-down of a combo box to list all the names that appeared in the Contacts column in a SharePoint list. The Contacts column is a multi-selection person/group column set to allow only people. Because it's multi-select, this results in a table (MS-speak for "array") in the Contacts field, instead of an object, and the Items property of a combo box can't handle a table (array). For increased performance, I loaded the items from the SharePoint list into a collection, and then built a second collection to house each of the person objects that appeared in the Contacts column.

First, I used the Ungroup function to basically rip each person object out of the Contacts column, and create a new record for each. I used the ShowColumns function on the result to limit the number of columns that would be in the new collection. Finally, I used the Collect function to create the new collection, and then applied the resultant collection to all items of the first collection using the ForAll function. Here's the OnVisible property of the screen...

Refresh('Action Items');
ClearCollect(MasterList, 'Action Items');
ForAll(MasterList,
    Collect(MasterContacts,
        ShowColumns(
            Ungroup(MasterList, "Contacts"),
            "ID",
            "Claims",
            "DisplayName",
            "Email"
        )
    )
);

 Back to the combo box in question. In the Items property, I can now enter the new MasterContacts collection, making sure to remove duplicates and sort appropriately.

Items property of combo box control...

Sort(
    Distinct(
        MasterContacts,
        DisplayName
    ),
    Result,
    Ascending
)

Since the Items property now refers to a single-column table of text values (one-dimensional String array), the Item property of the combo box can use it, and all the names appear in the drop-down once and only once, and in alphabetical order. Additionally, the SelectedText.Value property of the combo box now allows direct comparison to the DisplayName property of the person object in all other controls on the screen.

View solution in original post

Hi, @DanielGates!

Yes, that's essentially what I did, but I put it in the OnVisible property of a screen instead. I built a secondary collection that contained only the person/group objects in a table, and then pointed the Items property of the combo box to that new collection.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,674)