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 / Default user for Offic...
Power Apps
Answered

Default user for Office365Users.SearchUser search

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

In my app I'm searching for users within my org based on text from a label in my app. If there is no text in label it defaults to a user and I want to be able to control which user it defaults to.

 

Office365Users.SearchUser({searchTerm:SMEHiddenKey.Text, top:1})

 

SMEHiddenKey is the label that is being searched.

 

Any thoughts on how to change the default?

Categories:
  • RezaDorrani Profile Picture
    12,145 on at

    Hi @Anonymous 

     

    Add an if statement to check if the label is blank, if yes do not query search users

     

    Regards,

    Reza Dorrani

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks, @RezaDorrani .

     

    I'm fairly new to this and I'm having a hard time creating the statement. This is what I got so far:

     

    If(IsBlank(SMEHiddenKey), Office365Users.SearchUser({searchTerm:SMEHiddenKey.Text, top:1}))

    This is throwing all sorts of errors, so I'm sure I'm messing something up.

     

  • RezaDorrani Profile Picture
    12,145 on at

    @Anonymous 

     

    Do not worry, PowerApps is fun and easy

     

    Assuming you are using this formula on the Text property of a Label control, then the below should work

     

    If(IsBlank(SMEHiddenKey.Text),"",First(Office365Users.SearchUser({searchTerm:SMEHiddenKey.Text,top:1})).DisplayName)

     

    If you are using this formula on some other control property, please let me know

     

    Regards,

    Reza Dorrani

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @RezaDorrani  Thanks for helping out. I'm using this in a gallery under the Items property. I tried your formula and there is an error.

     

    Thanks!

  • Verified answer
    RezaDorrani Profile Picture
    12,145 on at

    Hi @Anonymous ,

     

    Use If(!IsBlank(SMEHiddenKey.Text),Office365Users.SearchUser({searchTerm:SMEHiddenKey.Text,top:1})) as Items Property for your gallery

     

     

    Regards,

    Reza Dorrani

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

     

  • chico Profile Picture
    638 on at

    thank you, 

    this little hint just gave me a good boost in my own little project!

  • jharville Profile Picture
    on at

    Hello! Quick question. I'm doing something similar and wondering what is it inside the parentheses of your search term. Is that the group of O365 Users you're trying to pull from?

     

    I am trying to use a combo-box to create a People-Picker from a specific group using O365 Users as a connector. 

     

    If the group of users in my O365 Users is called "testGroup" , AND my combo-box for my people-picker is called "testComboBox" , would this be the correct syntax for code? There are no errors when I input this code, but the combo-box isn't pulling up any results in my form. Thank you!

     

     

     

     

    Sort(
     Office365Users.SearchUser(
     If(
     IsBlank(testComboBox.SearchText),
     {searchTerm: "testGroup"},
     {searchTerm: testComboBox.SearchText}
     )
     ),
     Surname
    )

     

     

     

     

     

     

     

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 220 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 189 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 139

Last 30 days Overall leaderboard