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 / Pull User Information ...
Power Apps
Answered

Pull User Information based on AD LastName, FirstName

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi everyone,

 

I had created this post earlier, but I think it didn't get created. Couldn't find the post even when I searched for it, so giving it another go. 

 

I have a PowerApps form that is connected to a SharePoint Online list (please reference below):

 

image.png

 

 

The Default value for the Email Address field is:
First(Office365Users.SearchUser({searchTerm:Name.Text})).Mail

 

The Default values for Job Title and Department are similar, except the end of the string is replaced by .JobTitle and .Department.

 

This works great to return information for most users, but our organization has a group of users whose names follow a different naming standard, and their Display Names are ABCLastName, FirstName, and email addresses are FirstName.ABCLastName@Organization.com.

 

So when I use the above form to return user data, in order for the search to work, I'd have to enter in ABCLastName, FirstName. 

 

What I'm trying to do is to be able to return user data by only entering the LastName, FirstName. I figure it should be possible to query our AD for the user Last name and First name fields. Does anyone know how best to go about achieving this? I've spent a bit of time trying to find out a solution, but have so far been unable to do so.

 

Thanks in advance, everyone!

Categories:
  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous,

    Do you create a custom form for your SP list using PowerApps?

    The searchTerm property of the Office365Users.SearchUser() function is only applied to display name, given name, surname, mail, mail nickname and user principal name property of user profile. I suppose that your Office365Users.SearchUser() formula would filter Office 365 users based on display name or given name property (seaarchTerm applied to display name or given name).

    More details about the Office365Users.SearchUser() function, please check the following article:

    https://docs.microsoft.com/en-us/connectors/office365users/#search-for-users

    I have made a test on my side, please take a try with the following workaround:3.JPG

    Set the Default property of the TextInput control within the Email Address Data card to following (or set Default property of the Email Address Data card to following):

    First(
    Filter(Office365Users.SearchUser(),DataCardValue1.Text in DisplayName || DataCardValue1.Text in GivenName)
    ).Mail

    On your side, it should be:

    First(
    Filter(Office365Users.SearchUser(),Name.Text in DisplayName || Name.Text in GivenName)
    ).Mail

    Set the Default property of the TextInput control within the Job Title Data card to following (or set Default property of the Job Title Data card to following):

    First(
     Filter(Office365Users.SearchUser(),DataCardValue1.Text in DisplayName || DataCardValue1.Text in GivenName)
    ).JobTitle

    On your side, it should be:

    First(
     Filter(Office365Users.SearchUser(),Name.Text in DisplayName || Name.Text in GivenName)
    ).JobTitle

    Set the Default property of the TextInput control within the Department Data card to following (or set Default property of the Department Data card to following):

    First(
     Filter(Office365Users.SearchUser(),DataCardValue1.Text in DisplayName || DataCardValue1.Text in GivenName)
    ).Department

    On your side, it shoud be:

    First(
     Filter(Office365Users.SearchUser(),Name.Text in DisplayName || Name.Text in GivenName)
    ).Department

    The GIF screenshor as below:Test1.gif

     

     

     

    Best regards,

    Kris

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 382 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard