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 / Office365Users.SearchU...
Power Apps
Answered

Office365Users.SearchUserV2 In Combox Fails When Searching By GivenName and Surname

(0) ShareShare
ReportReport
Posted on by 6

Hello,

 

I have a combobox with its Items property set to the below. The DisplayName property within AAD is in the format of Surname, GivenName, which means users have to search according to that format (i.e., "Doe, John").

 

This is why I created the FullName property in the Filter function below, such that users could search in a more natural way (GivenName + a space + Surname).

 

I have the Search Fields property set to ["FullName"] and have confirmed (via setting the DisplayFields property to ["FullName"]) that the FullName value is correct - i.e., "John Doe".

 

However, if a user enters a space after the GivenName in the combobox's search string, the search breaks. I.e., if they search "John", all the Johns appear as expected. As soon as they enter a space to begin the last name, all results that were returned with "John" disappear.


I have experimented with trimming the searchTerm value in the SearchUserV2 function, but this just makes it so the results disappear on the first character of the Surname as opposed to the space.

 

Why is the search behaving like that?

 

 

Filter(
 SortByColumns(
 AddColumns(
 AddColumns(
 Office365Users.SearchUserV2(
 {
 searchTerm: Self.SearchText,
 isSearchTermRequired: false
 }
 ).value,
 "UserDisplayData",
 Concatenate(
 ThisRecord.GivenName,
 " ",
 ThisRecord.Surname,
 " | ",
 ThisRecord.JobTitle
 )
 ),
 "FullName",
 Concatenate(
 ThisRecord.GivenName,
 " ",
 ThisRecord.Surname
 )
 ),
 "Surname"
 ),
 AccountEnabled = true && Not("#EXT" in UserPrincipalName) && Not("(External Vendor)" in UserPrincipalName) && Not(IsBlank(GivenName))
)

 

 

Categories:
  • Verified answer
    WiZey Profile Picture
    3,023 Moderator on at

    Hello @dbdfsgf45 ,

     

    This is my hypothesis, but I'm thinking this is what's stopping you:

     

    Office365Users.SearchUserV2(
     {
     searchTerm: Self.SearchText,
     isSearchTermRequired: false
     }
     ).value

     

    Even though your dropdown is set to search on the "Fullname", you still have this "Office265Users" connector using the same "SearchText" and returning different values whenever the user input a more complete identity.

     

    Maybe try with something like this?

     

    Office365Users.SearchUserV2(
     {
     searchTerm: First(Split(Self.SearchText, " ")),
     isSearchTermRequired: false
     }
     ).value

     

    You split the "SearchText" and give the first value (supposedly the "Surname") to the connector so it doesn't start behaving unexpectedly.

  • dbdfsgf45 Profile Picture
    6 on at

    Thank you for this, WiZey! Your hypothesis was correct I believe - at least for what I wanted to achieve.

     

    Just a note for others looking to implement WiZey's solution, ensure that, in the searchTerm property of the SearchUserV2 function, you give it the Value of the First function.

     

    I.e...

    Office365Users.SearchUserV2(
     {
     searchTerm: First(Split(Self.SearchText, " ")).Value,
     isSearchTermRequired: false
     }
     ).value

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

#2
WarrenBelz Profile Picture

WarrenBelz 190 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard