cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Gallery to display Office 365 user info from textbox that has multiple names

I'm using the following formula on my gallery items property to receive information for a user:

 

Office365Users.SearchUser({searchTerm:lblInternalOwnerHidden.Text})

This works perfectly when there is only 1 name in lblInternalOwnerHidden field, but when there are multiple values (separated by a semi-colon) the gallery comes back empty.

 

Is there a way I can modify the formula to account for when there are 1 or multiple users?

1 ACCEPTED SOLUTION

Accepted Solutions

@Anonymous 

So, yes, you can take that list and use it for your Gallery.  Here is what you would use on the Items property of the Gallery:

 

ForAll(
Split(lblInternalOwnerHidden.Text, ";"),
First(Office365Users.SearchUser({searchTerm:Trim(Result)}))
)

This will split the label by the semicolon and then perform a search on each name (trimmed for spaces).

You'll note that this also narrows the result to the first record returned.

 

This will work but you could run into issues with names like, for example, "Bill Johns" in the label, but you have both a Bill Johns and Bill Johnson in the 365 user list.

 

Give that formula a try and see if that works for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

5 REPLIES 5
RandyHayes
Super User III
Super User III

@Anonymous 

No, not using that function...

But, I am wondering about the text in the Label you reference in it.  You mentioned TextBox in your post title, but the formula looks like you might be referencing a Label. 

So, if it is a Label, where is it coming from and are the names or information in it complete?

In other words, SearchUser will search for users by "incomplete" information.  So If I searched for "Un", I would get UnitedLexAdmin, UnitedUser, etc. etc.  If I searched for "UnitedLexAdmin" I would get one result. 

So, if the names in the Label are "complete" names, then you could split the text of the label into separate names and the collect the results of the search of each name.  That's one option.  There are others, but it really depends on what you have in that label to search/use.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes
Anonymous
Not applicable

Thanks, @RandyHayes .

 

I am referencing a label that is reading from a SharePoint text field and the names are complete.

 

Do you have any suggestions on how I could split the text of that label (delimited by semi-colon) and get the results for each of the names? Would I need to make a collection?

Pstork1
Dual Super User III
Dual Super User III

I think you are misinterpreting the way the method works.  When doing property searches in traditional sharepoint you needed to include the property being searched for each term.  So in regular search it would translate to 'Searchterm:User1@domain.com OR Searchterm:User2@domain.com'. I don't think you can pass it a comma delimited string of values.

 

It can be used to return multiple users, but it searches the words in each user's Display Name for matches that StartWith the term.  That's what the ':' operator denotes in Keyword Query language.  So if I search for 'P' it will give me matches for Paul Stork, Rob Phillips, and Peter Brown, but not for John Doe.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@Anonymous 

So, yes, you can take that list and use it for your Gallery.  Here is what you would use on the Items property of the Gallery:

 

ForAll(
Split(lblInternalOwnerHidden.Text, ";"),
First(Office365Users.SearchUser({searchTerm:Trim(Result)}))
)

This will split the label by the semicolon and then perform a search on each name (trimmed for spaces).

You'll note that this also narrows the result to the first record returned.

 

This will work but you could run into issues with names like, for example, "Bill Johns" in the label, but you have both a Bill Johns and Bill Johnson in the 365 user list.

 

Give that formula a try and see if that works for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

Anonymous
Not applicable

@RandyHayes  You are a genius! This worked perfectly and I learned something new. Thanks so much for the assistance.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,009)