cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
UnitedLexAdmin
Level: Powered On

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
Super User
Super User

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

@UnitedLexAdmin 

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.

5 REPLIES 5
Super User
Super User

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

@UnitedLexAdmin 

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.

UnitedLexAdmin
Level: Powered On

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

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
Level 8

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

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.

Super User
Super User

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

@UnitedLexAdmin 

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.

UnitedLexAdmin
Level: Powered On

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

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