Are you looking to streamline user selection in your Power Apps application? Leveraging the Office365Users connector can help you list all users in a Combo box and make it more meaningful. In this article, I'll walk you through the steps to achieve this.
Different properties of Combo box:
Items: Top is optional parameter defines no of records to be retrieved
formula: Office365Users.SearchUserV2({searchTerm:Self.SearchText,top:10,isSearchTermRequired:false}).value
DefaultSelectedItems : this property helps to select default values of combobox.
- Below formula helps you to select logged in user as default
First(Office365Users.SearchUserV2({searchTerm:User().Email,top:10,isSearchTermRequired:false}).value)
- If you want to Select Multiple Persons as default
ForAll(Split("firstpersonemail;secondpersonemail",";"),First(Office365Users.SearchUserV2({searchTerm:ThisRecord.Value,top:10,isSearchTermRequired:false}).value))
DisplayFields & SearchFields:
The distinction between single and double display fields becomes evident when selecting a person. Double display fields offer the advantage of displaying two attributes simultaneously. For instance, if configured as per above pic, users will see both the display name and email address, providing a more comprehensive view during the selection process.
The Search field serves as the designated field within the retrieved items where you perform searches, thereby enhancing the precision and efficiency of your user selection process.
Multiple Selection and Searching:
If you intend to choose just one user, disable the option for multiple selections to ensure a single-user selection process.
Enabling the "Allow searching" feature empowers users to conveniently search for the specific individual they need using the designated search field attribute. If you disable this feature, users will be required to manually scroll through the list to make their selection, which may be less efficient.
Scenarios:
- When you want to select the users based on specific criteria from some specific department or with some specific title etc.
- When you want to select the users from only specific group
For the second scenario, you can retrieve the relevant persons using the following code:
items: Office365Groups.ListGroupMembers("urgroupobjid").value
This code allows you to populate the selection options with users from the specified group, making your user selection process more tailored and meaningful.
Recommendations:
To prevent confusion, it's crucial to ensure that the attribute chosen as the primary text value is not empty. Be diligent in selecting an attribute that consistently contains meaningful data, as an empty attribute can lead to ambiguity and usability issues.