Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Query
Unanswered

Multiple default selected items for combobox with office365users as combobox datasource

(2) ShareShare
ReportReport
Posted on by
have a combobox that has the following code as the items property
 
 
 
 
It is multi-select and works fine. It saves a concatenated string of the selected users display name into a field, and a concatenated string of the users email into a separate field.
 
 
 
ex. Name field "Bill Bilson, Tod Todson"
 
ex. Email Field "BillBillson@website.com, TodTodson@website.com"
 
 
 
I have no issue retrieving just one user to the default selected property using either of these lines of code
 
First(Office365Users.SearchUserV2({searchTerm:varRecord.'Project Owner Email'}).value)
 
 
or 
 
LookUp(Office365Users.SearchUser({searchTerm:varRecord.'Project Owner Email',top:1}),DisplayName = ThisItem.'Project Owner Name')
 
 
My issue comes when I try and set multiple users as the default selected item property using the following code



 
Filter(Office365Users.SearchUserV2({searchTerm:varRecord.'Project SME Email',top:10}).value,DisplayName in VarDefaultSME)
 
 
 
varRecord.'Project SME Email' = string of users emails that are saved to Dataverse and I wish to populate as the defualt selected items
 
 
 
ex."BillBillson@website.com, TodTodson@website.com"



 
VarDefualtSME.Value is a table that consist of the users FULL Names in a table
 
 
 
Any ideas on where I am making a mistake here? Thanks!
 
 
 

 
Categories:
  • MarkRahn Profile Picture
    1,057 Super User 2025 Season 1 on at
    Multiple default selected items for combobox with office365users as combobox datasource
     
    I created a Test App to see if I could help you out. I think your issue is with what you have your SearchField set to in Fields:
     
    It should be set to "Mail".
     
    I added two comboboxes and a button.
     
    For ComboBox1, this is the relevant code:
    - ComboBox1:
        Control: Classic/ComboBox@2.4.0
        Properties:
          DisplayFields: =["DisplayName"]
          Items: =Sort(Office365Users.SearchUser({searchTerm:(Self.SearchText),top:(999)}),DisplayName,SortOrder.Ascending)
          SearchFields: =["Mail"]
     
     
    For Button1, this is the relevant code:
    - Button1:
        Control: Classic/Button@2.2.0
        Properties:
          OnSelect: |-
            = Set(varStringOfEmails, Concat(ComboBox1.SelectedItems, Mail, "; "));
     
     
    I set a variable to be the string of Mail values selected which is what you said you are storing in the DataVerse field.
     
    All of this was just to be able to capture some selected Users to use in ComboBox2 which has this relevant code:
    - ComboBox2:
        Control: Classic/ComboBox@2.4.0
        Properties:
          DefaultSelectedItems: |-
            =Filter(
                Office365Users.SearchUser({ searchTerm: "", top: 999 }),
                Mail in Split(varStringOfEmails, "; ")
            )
          DisplayFields: =["DisplayName"]
          Items: =Sort(Office365Users.SearchUser({searchTerm:(Self.SearchText),top:(999)}),DisplayName,SortOrder.Ascending)
          SearchFields: =["Mail"]
     
    So for your example, set your SeachFields to ["Mail"] and set your DefaulSelectedItems to :
     
    Filter(
                Office365Users.SearchUser({ searchTerm: "", top: 999 }),
                Mail in Split(varDefaultSME, ", ")
            )
     
    "Mail" is the email address field in Office365Users. "DisplayName" is the user's full name. This is why you are unable to get things to match up. You are storing a concatenated list of users email addresses and then trying to filter Office365Users on the DisplayName field.
     
    I hope this helps you. Let me know if you are still having issues.
     
    This community is supported by individuals freely devoting their time to answer questions and provide support. They do it to let you know you are not alone. This is a community.

    If someone has been able to answer your questions or solve your problem, please click Does this answer your question. This will help others who have the same question find a solution quickly via the forum search.

    If someone was able to provide you with more information that moved you closer to a solution, throw them a Like. It might make their day. 😊

    Thanks
    -Mark

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >

Featured topics