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

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?


Accepted Solutions
Microsoft Employee

Re: How to search Office365Users by location or department?

 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.


All Replies
Microsoft Employee

Re: How to search Office365Users by location or department?

 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.

Super User Rank
Super User

Re: How to search Office365Users by location or department?

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.

RHCC
Level: Powered On

Re: How to search Office365Users by location or department?

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!

Microsoft Employee

Re: How to search Office365Users by location or department?

@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. 

RHCC
Level: Powered On

Re: How to search Office365Users by location or department?

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!

Microsoft Employee

Re: How to search Office365Users by location or department?

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