Skip to main content
Community site session details

Community site session details

Session Id : NBdj1oy+0KuidTC4RGQ25h
Power Automate - Building Flows
Answered

Search for job title

Like (0) ShareShare
ReportReport
Posted on 9 Mar 2022 17:41:04 by 1,934 Super User 2025 Season 1

Is it possible to search for a user's email based on his job title? I'm using Search for users (V2). It works fine when you use the person's name, but searching for Director returns [].

 

Thanks,

Anne

  • Verified answer
    Community Power Platform Member Profile Picture
    on 07 Apr 2023 at 22:23:36
    Re: Search for job title

    Great solution. 

  • Kamz Profile Picture
    131 on 15 Dec 2022 at 21:01:33
    Re: Search for job title

    I got it to work with eq, but I need to search non-definitive. For example perhaps their position isn't "Director" it may be "operations director"

     

    I've been trying to use contains and substringof but neither seem to work. I'm trying to find a way to allow the user to type a skill and have it search for an employee with that skill in their job title.

     

  • Verified answer
    annetoal Profile Picture
    1,934 Super User 2025 Season 1 on 22 Sep 2022 at 13:27:25
    Re: Search for job title

    After the step where you send the HTTP request to Sharepoint, parse the JSON of the output using this (I used the name Parse JSON for the connector, which you will see in the next step.)

     

    {
     "type": "object",
     "properties": {
     "d": {
     "type": "object",
     "properties": {
     "__metadata": {
     "type": "object",
     "properties": {
     "id": {
     "type": "string"
     },
     "uri": {
     "type": "string"
     },
     "type": {
     "type": "string"
     }
     }
     },
     "Alerts": {
     "type": "object",
     "properties": {
     "__deferred": {
     "type": "object",
     "properties": {
     "uri": {
     "type": "string"
     }
     }
     }
     }
     },
     "Groups": {
     "type": "object",
     "properties": {
     "__deferred": {
     "type": "object",
     "properties": {
     "uri": {
     "type": "string"
     }
     }
     }
     }
     },
     "Id": {
     "type": "integer"
     },
     "IsHiddenInUI": {
     "type": "boolean"
     },
     "LoginName": {
     "type": "string"
     },
     "Title": {
     "type": "string"
     },
     "PrincipalType": {
     "type": "integer"
     },
     "Email": {
     "type": "string"
     },
     "Expiration": {
     "type": "string"
     },
     "IsEmailAuthenticationGuestUser": {
     "type": "boolean"
     },
     "IsShareByEmailGuestUser": {
     "type": "boolean"
     },
     "IsSiteAdmin": {
     "type": "boolean"
     },
     "UserId": {
     "type": "object",
     "properties": {
     "__metadata": {
     "type": "object",
     "properties": {
     "type": {
     "type": "string"
     }
     }
     },
     "NameId": {
     "type": "string"
     },
     "NameIdIssuer": {
     "type": "string"
     }
     }
     },
     "UserPrincipalName": {
     "type": "string"
     }
     }
     }
     }
    }

     

    It will expose the email address. Store the email address in a string variable using this expression

     

    body('Parse_JSON')?['d']?['Email']

     

    You can then insert this variable into the email connector you're using to send the mail.

  • Expiscornovus Profile Picture
    32,155 Most Valuable Professional on 22 Sep 2022 at 13:09:28
    Re: Search for job title

    Hi @OliverJulie,

     

    You could use an expression for that to retrieve the mail value of the first item it found in the output.

     

    Below is an example expression which you should be able to use in the To field.

    body('Send_an_HTTP_request')['value'][0]['mail']

     

    expression_email.png

  • OliverJulie Profile Picture
    2 on 22 Sep 2022 at 12:47:44
    Re: Search for job title

    The HTTP request step worked well.But how do I send email to this user? I tried using the HTTP request output body, but it didn't work

  • Expiscornovus Profile Picture
    32,155 Most Valuable Professional on 10 Mar 2022 at 16:12:37
    Re: Search for job title

    Hi @annetoal,

     

    Great to hear it works for you with the Office 365 Groups connector 😀

     

    That error of the Invoke HTTP request might be because I forgot one thing to mention, my bad 😅 

     

    You need to use the https://graph.microsoft.com url in the connection of that action for the Base Resource URL and Azure AD Resource URI. 

     

    CreateConnection_BaseResourceURL.gif

  • annetoal Profile Picture
    1,934 Super User 2025 Season 1 on 10 Mar 2022 at 15:49:40
    Re: Search for job title

    @Expiscornovus That works. Thank you so much. Incidentally, I found I could use the Premium connector, but I am afraid I still don't have some access right, because using it produced the error

     

    Access token validation failure. Invalid audience.

     

    But using the non-Premium connector you mentioned worked and produced the output I needed. Thanks again.

     

    Anne

  • annetoal Profile Picture
    1,934 Super User 2025 Season 1 on 10 Mar 2022 at 14:17:14
    Re: Search for job title

    Thanks for explaining the behavior of the search function. I will give it a try and post what happens.

     

    a

  • Krzysztof Borkowski Profile Picture
    Microsoft Employee on 10 Mar 2022 at 14:14:41
    Re: Search for job title

    If your goal is to get the Director, and there is only 1 director in your company with a Job Title = Director, you don't care about his/her name. The empty search will return every employees and the filter will list your only those/that Employee who owns the current Job Title. You can than return his/her name, nickname, email, upn, phone nr whatever you want. It will be John, and when John leaves or change his position and the new Director will be Mary the flow will return Mary. You can also create a recurrance trigger that will check daily who is currently the director, if there will be noone you can send and e-mail to your HR group to hire one 🙂

  • annetoal Profile Picture
    1,934 Super User 2025 Season 1 on 10 Mar 2022 at 14:03:01
    Re: Search for job title

    I understand that I can search for a Director's name, e.g. John Smith is a Director so searching for his name gives me a Director in the Job Title. But what I want to do is make the Flow able to survive changes in personnel. So if John Smith leaves the organization, and the Flow is searching on his name, then it starts returning a null.

    But what I want is to search on a Title, and return the email address of that title. Because if John leaves the organization, another example, Mary Doe will replace him as Director. So after the personnel change, the Flow would start to return Mary's email address instead of a null. That way I protect the Flow from failure everytime there's a staff change.

    You're telling me that you can't input a Title into the search parameter, so that's out. It looks like @Expiscornovus has a solution but unfortunately it's unavailable to me. So it's looking like I am going to have to hard-code an individual name into the search 😞 Oh Well...

     

    If you think of a better way, please let me know.

    Thanks,

    Anne

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1