Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
Suggested answer

Get User Profile from string

(1) ShareShare
ReportReport
Posted on by 403
Hi all,
 
I'm working on a Power App and the data that was given has a column type of string with users name in the following format (firstName lastName). I need to be able to pull their account using O365 connector in a combo box, but I haven't been successful. 
 
Has anyone tried this in the past? if so, can you please point me in the right direction? 
 
Cheers,
  • Suggested answer
    WarrenBelz Profile Picture
    146,953 Most Valuable Professional on at
    Get User Profile from string
    Your issue here is that you only have the name and you need to retreive enough of the profile to then update the data card containing the user you have referenced. I will assume here that the name of the user is in a Text Box and you have a Combo Box searching other users if required and want the details defaulted (both controls are classic items in this example). This is also assuming new records only (see below for existing records also) .
     
    Firstly the Items of the Combo Box
    Office365Users.SearchUserV2(
       {
          SearchTerm: Self.SearchText,
          isSearchTermRequired: false
       }
    ).value
    and DisplayFields
    ["DisplayName"]
    and DefaultSelectedItems
    {
       DisplayName: YourTextInputName.Text,
       Mail: First(Office365Users.SearchUserV2({searchTerm: YourTextInputName.Text}).value).Mail
    }
    Now the Update of the Data Card
    {
       Claims: "i:0#.f|membership|" & Lower(ComboBoxName.Selected.Mail),
       Department: "",
       DisplayName: ComboBoxName.Selected.Mail.DisplayName,
       Email: ComboBoxName.Selected.Mail,
       JobTitle: "",
       Picture: ""
    }
    If you want to work with existing records also, the DefaultSelectedItems would be something like
    If(
       YourFormName.Mode = FormMode.New,
       {
          DisplayName: TextInput8.Text,
          Mail: First(Office365Users.SearchUserV2({searchTerm: YourTextInputName.Text}).value).Mail
       },
       {
          DisplayName: ThisItem.YourPersonField.DisplayName,
          Mail: ThisItem.YourPersonField.Email
       }
    )
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee
  • _sourcecod3_ Profile Picture
    403 on at
    Get User Profile from string
    Hi @EE-04041031-0,thanks for your response, but that did not work. 
     
    This line doesn't populate anything: Office365Users.SearchUser({searchTerm: TextSearchBox1.Text})
     
  • EE-04041031-0 Profile Picture
    80 on at
    Get User Profile from string
    ✅Yes, you can use the Office365Users connector to resolve a user's full name to their account. In your ComboBox `Items` property, use:
    Office365Users.SearchUser({searchTerm: TextSearchBox1.Text})
    Then set:
    - `DisplayFields` = ["DisplayName"]
    - `SearchFields` = ["DisplayName"]
    - `DefaultSelectedItems` (if needed) = LookUp(Office365Users.SearchUser({searchTerm: "John Doe"}), DisplayName = "John Doe")
     
    Since you're starting with full names as strings, you’ll need to pass the name to `SearchUser` and handle possible duplicates manually.
     

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 55 Most Valuable Professional

#2
mmbr1606 Profile Picture

mmbr1606 42 Super User 2025 Season 1

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 31 Super User 2025 Season 1

Overall leaderboard