web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Combobox with Office36...
Power Apps
Unanswered

Combobox with Office365Users.searchuser and hints

(0) ShareShare
ReportReport
Posted on by 8

Does anyone know how to make a combobox with a search field looking for users in my A.D., but with the names chosen recently on the top of the list. IE: I have a gallery of people, some fields are blank. Some fields have entries in them already. I have a collection of distinct names of people I've chosen already, and need to have them on top of the list of all other combobox search criteria.
For example, if "Fred" and "Mary" have already been chosen, then on the next combobox the user clicks on, "Fred" and "Mary" should be the two entries on the top of the list, and other users in AD below. If the user starts typing anything in the search/filter text field of the combobox, the search criteria should kick in (Office365Users.search) and show results accordingly, as normal.

Thanks in advance!

Categories:
I have the same question (0)
  • Tchesco Ayih Profile Picture
    152 on at

    @MikeSophon 

     

    Let me get you well, you have a gallery and a combobox and both of these controls search users in the AD. And in addition the combobox filter and display on top users already selected in the gallery. Let me know if this is your case.

  • MikeSophon Profile Picture
    8 on at

    Mostly.  Pretty close. Just to make sure I get you right, I have a combobox IN a gallery; The gallery contains one combobox per line. Each combo box is for a person's name.

    Imagine a task list, and you want to assign people to tasks.  You have a gallery of tasks.  Each task either already has a person's name in it, or is blank. For the blank ones, you want to assign a person.  But what if you have 300,000 people in your organization? That's too much of a pain to filter through all those people.  However, if you have assigned tasks already to 3 different people, then the odds are pretty high that the next tasks you assign are probably going to be one of those 3 people.  So, I have a collection of "distinct aready chosen people" that I want to be at the top of the search list when the user wants to assign a task.  Call it a "favorites" list.  So I want to combine the results of the Office365Users.SearchUser({searchTerm:ComboBox1.SearchText,top:20}) with my distinct list of "favorites" somehow so the search box searches both lists at the same time as the user types in it.

     

  • MikeSophon Profile Picture
    8 on at

    ...but at this point, I'm a little desperate, and am happy to compromise on functionality in order to proceed with the rest of the app.. any hints on how maybe to have .. I dunno... a custom component that has one regular combobox with the search list (Office365Users.SearchText) and another right above with the smaller set of recently chosen distinct names?) Ideas?

     

  • Tchesco Ayih Profile Picture
    152 on at

    @MikeSophon 

    Check if this works:

    On the OnChange property of the ComboBox put this: 

    Collect(MyList, ComboBox1.SelectedItems);
    ClearCollect(MyFavList, ForAll(Distinct(MyList, ThisRecord.DisplayName), Result))

    This formula compare and remove any duplicated records.

    Now on the Items Property of the ComboBox, add this:

    Sort( Office365Users.SearchUser({searchTerm:ComboBox1.SearchText,top:20}), DisplayName in myFavList, Descending)

    This compare the MyFavList with the Office365Users list and bring those in the MyFavList first.

     

    Hope this will help.

  • MikeSophon Profile Picture
    8 on at

    Thanks for the reply!

    I assume you meant "MyFavList" in the Sort function? (Instead of myFavList) Also, while the names in MyList were added (and correctly maintained) in the MyFavList collection, oddly, when clicking on an empty combobox somewhere in the gallery, none of the names in MyFavList showed up in the 20 search results. It was just the first 20 matches of the AD search, and nothing else.  (And yes, there were exactly 20 matches)

    Also, while I'm sure it's a very clever hack, I don't think I understand the Sort function you're using, you are specifying the search results to be sorted, but when you're specifying the column name, you're referring to a different collection ("in myFavList")... what does this do?

    Clues? Thoughts?

    Thanks again!

  • Tchesco Ayih Profile Picture
    152 on at

    Ok my mistake (myFavList is actually MyFavList), remove the part that bring only 20  search records. (I was using it for testing).

    Office365Users.SearchUser({searchTerm:ComboBox1.SearchText})

    Normally this bring the users in the AD, and the Sort take the Names in the MyFavList and locate the in the AD and bring them first.

    Have you try it? Let me know if it is ok.

  • MikeSophon Profile Picture
    8 on at

    Yeah, The hit max is useful, I use it too.  I wouldn't want to trash performance by always returning a huge pile of results.  I already used the MyFavList instead of just myFavList, and it's not working.  I don't see any names from the distinct username list (in the collection MyFavList).  I just see the results from Office365users.searchuser. Is there some other setting I should be playing with?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 408

#2
timl Profile Picture

timl 340 Super User 2026 Season 1

#3
Vish WR Profile Picture

Vish WR 319

Last 30 days Overall leaderboard