web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Search for users based...
Power Automate
Unanswered

Search for users based on departement and job title

(0) ShareShare
ReportReport
Posted on by 32

Hello everyone!

Background:
An app connected to a SharePoint list containing information that will be used to search for other users when the task is completed. 

 

Case:
An operator submits an entry to the list. The maintenance guy checks a box when he is finished and then the flow starts. The affected department is submitted to the list and the managers for that department want an email when "fixed" box is checked. 

 

No problem with extracting the information. 
The problem is filtering or searching for those managers for the department.

 

Does anyone have a good idea? 

Frigge___0-1662368017500.png

 

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @Frigge__,

     

    As far as I am aware Search for Users (v2) only looks for keywords within the display name, given name, surname, mail, mail nickname and user principal name fields.

     

    However, as a workaround you could use the Graph API for this and $filter for Department and $expand on manager in the List Users method.

     

    Below is an example.

    In this example I used the Send an HTTP request action from the Office 365 Groups connector. After that the manager mail address are retrieved via a Select and an intersection function is used to only retrieve the distinct manager mail addresses.

     

    https://graph.microsoft.com/v1.0/users/?$select=Department&$filter=Department eq '@{variables('DepartmentName')}'&$expand=manager($levels=max;$select=mail)

     

    listofmanagers_forspecificdepartment.png

     

  • Frigge__ Profile Picture
    32 on at

    @Expiscornovus 

     

    As far as I am aware Search for Users (v2) only looks for keywords within the display name, given name, surname, mail, mail nickname and user principal name fields.

    I think you're correct about that, I can't find anything suggesting otherwise

    I tried your solution, but couldn't get it to work. With HTTP action won't give me anything in return. Tried different approaches as well.

    The easiest way to solve it would be to "hard code" the names and send the emails that way, but if they change the manager this work has to be redone. ( I know, I'm lazy.. 😂)

    I might try to find another solution. 

  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @Frigge__ 

     

    With the regular HTTP action you need to also configure authentication settings (like OAuth and register an app in Azure AD with the correct Graph API permissions).

     

    That's why I suggested to use the Send an HTTP request action from the Office 365 Groups category. That one does not require that setup.

     

    Just to double check, did you try that action as well?

  • Frigge__ Profile Picture
    32 on at

    Hi @Expiscornovus,

     

    I tried 3 different actions of getting the information via that HTTP. I also went to the Graph Explorer to check but couldn't get anything but error.

    The URL looks fine and it gets the correct department input name for the request. 

    Frigge___0-1662445553647.png

     

    I think I'll put the names in to a separate list and fetch them from that list. 

     

  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @Frigge__,

     

    The third one seems valid, only the results are empty. Might be a data related thing. So, it is worth checking with Graph Explorer to investigate.

     

    If you want to test in Graph Explorer you need to remove the / just before the ?. I used that to escape the ? character to make it valid for the Send an HTTP request action.

     

    Try this in the Graph Explorer instead:

    https://graph.microsoft.com/v1.0/users?$select=Department&$filter=Department eq '@{variables('DepartmentName')}'&$expand=manager($levels=max;$select=mail)

     

    And also try this as well in Graph Explorer. Just to see if the $filter works:

    https://graph.microsoft.com/v1.0/users?$select=Department&$filter=Department eq '@{variables('DepartmentName')}'

     

  • Frigge__ Profile Picture
    32 on at

    Hi @Expiscornovus 

    This would probably work if the company had made it possible. 
    So I made it static and directed the mail manually. 

     

    Thanks for the response, I might get back to this when there's more time as well. 😁

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard