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

How to search Office365Users by location or department?

The documentation for the SearchUser function states that it only applies to: display name, given name, surname, mail, mail nickname, and user principal name.

 

I want to design a PowerApp that will pull a list of all current Locations or Departments for users in my organization, and then list all users who work at that Location or Department. If the SearchUser function won't let me search by these fields, is there some other way to do it?

1 ACCEPTED SOLUTION

Accepted Solutions
dinusc
Microsoft
Microsoft

 You should be able to use Filter function to filter the results of the Office365Users.SearchUser by Location or Department. The "catch" here is that this will work only if the number of users in your organiation does not exceed the maximum nuber of rows per connector. That value is 500 by default and it can be increased to up to 2000.

View solution in original post

11 REPLIES 11
dinusc
Microsoft
Microsoft

 You should be able to use Filter function to filter the results of the Office365Users.SearchUser by Location or Department. The "catch" here is that this will work only if the number of users in your organiation does not exceed the maximum nuber of rows per connector. That value is 500 by default and it can be increased to up to 2000.

View solution in original post

BitLord69
Power Participant
Power Participant

Might be increased I want to add. In some of my apps I tried changing the limit but then the apps stopped working; I  get a lot of error messages when trying to access the resources.

 

Perhaps it is because I use views. Other than that I'm not doing anything out of the ordinary.

Hi @dinus, 

I would be willing to try your idea, as several methods online have not worked thus far. Would you please care to elaborate on how you might execute something like this using the PowerApps platform? Thank you!

@RHCC, My suggestion was to provide a search string that would match all the users and then filter the search results: For example, let's say that you need to list all the users from all the departments that have the word "consult" in the name ("Consulting Department" for example). You could use something like the following:

Filter(Office365Users.SearchUser({searchTerm:"."}), "consult" in Department)

The "searchTerm" should evaluate to all the users since it also searches by emails and all the emails should contain "." (period).

Please note that this should work in case the number of users in your organization is less than the maximum number of records pulled by connector (500 by default that can be increased up to 2,000)

 

@BitLord69,

I suspect that the crash after increasing the number of records is not related to views but rather to the amount of data pulled. This should be the case when the source that you use has many columns. My guess is that your device runs out of memory. 

Thanks for the quick response, @dinusc! However, I realize now that my problem is different than what is described here.

 

I am trying to create a search box that will search not only the user's name, but also search across other parameters like Job Tile and Department. So if someone types in Karen, they find all the Karens, but if they type in "market" all Marketing department members or anyone with "Market" in their title would pop up, even if it was a partial search.

 

From what I understand, there are a few ways to filter search results, but how could I search on other parameters besides the Display Name? I may need to create my own post for this, and if so I can do that. Feel free to let me know what you recommend. Thank you!

Would not something line the following work? Filter(Office365Users.SearchUser({searchTerm:"."}), TextInput1.Text in Department Or TextInput1.Text in JobTitle)

@RHCC I am having same issue.

Did you find any solution for this issue?

Thanks

Hey Ptiwari. New here. Did you ever find a solution for this? Thanks. 

Welp, never saw this. Busy life and all - my apologies. Anyways I was never able to figure this out, so instead...

-----------

Basically I just made a search bar looking at one value, Employee Name, then used a filter for the other parameter, department.

 

- The page has a search bar and a drop down control at the top, then below is a gallery control.

 

- "Search bar" is named 'inpSearchBar' in Power Apps

 

- There is a Department dropdown. The Dropdown items are generated by using a collection, 'colDEPT', which is pulling the Department choices from the SharePoint list on app launch. I am using this in the Items property of the App Start to grab the department values to be used in the dropdown: ClearCollect(colDEPT,Choices('[SharePoint List]'.Department))

 

- "Items" property on the gallery below it:
SortByColumns(Filter('[SharePoint List]',StartsWith('Employee Name',inpSearchBar.Text),Department.Value=Dropdown1.Selected.Value),"Start Date",Ascending)

 

- It may not be exactly what is asked for in this but figured I'd tie this loose end. I got a thing about loose ends 🙂

 

If anybody ever has questions, please feel free to private message me. 

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 (39,506)