cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
FelipeLeite
Helper I
Helper I

Filter City in Office365Users.SearchUser() function

Hi 🙂

I have a gallery that uses the Office365Users.SearchUser() function, but I don't want the gallery to show all employees. I want the gallery to show only employees where ThisItem.City = "TEK".

How can I insert this condition for City into my Office365Users.SearchUser() function?

1 ACCEPTED SOLUTION

Accepted Solutions

Use this mate, picking up on what @RandyHayes said:

 

Search(Office365Users.SearchUserV2({searchTerm:Trim(TextInput1.Text)}).value,TextInput2.Text, "City"))

 

On TextInput1 box you can search for a user's name, on TextInput2.Text you type TEK

 

This will give you the result you want. it will let you dynamically search for both user and city. Today you might want to search for TEK, but tomorrow you might need to search for something else. 

View solution in original post

5 REPLIES 5
RandyHayes
Super User III
Super User III

@FelipeLeite 

Please consider changing your Formula to the following:

Filter(Office365Users.SearchUserV2().value, city="TEK")

 

I hope this is helpful 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
jbrit2020
Responsive Resident
Responsive Resident

Do you want it hardcoded? Don't advise you to hardcode it. Add a second textinput box and then on the gallery put this:

 

Search(Office365Users.SearchUser({searchTerm: Trim(TextSearchBox1.Text), Top: 30}),TextInput2.Text,"City"))

 

This should do the trick

RandyHayes
Super User III
Super User III

@jbrit2020 

No, I'd not advise hard coding either.  Good suggestion if it is needed.

However, SearchUser is deprecated, please start using V2 to avoid issues going forward.

_____________________________________________________________________________________
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

Hi, @RandyHayes 

I tried using this code, but it doesn't give me any data in the gallery.

However, if I use the function without any condition for City, the gallery brings me all the data.

Do you know what it can be?

Use this mate, picking up on what @RandyHayes said:

 

Search(Office365Users.SearchUserV2({searchTerm:Trim(TextInput1.Text)}).value,TextInput2.Text, "City"))

 

On TextInput1 box you can search for a user's name, on TextInput2.Text you type TEK

 

This will give you the result you want. it will let you dynamically search for both user and city. Today you might want to search for TEK, but tomorrow you might need to search for something else. 

View solution in original post

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

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (12,875)