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
Great solution.
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.
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.
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']
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
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.
@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
Thanks for explaining the behavior of the search function. I will give it a try and post what happens.
a
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 🙂
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
Michael E. Gernaey
497
Super User 2025 Season 1
David_MA
436
Super User 2025 Season 1
Riyaz_riz11
244
Super User 2025 Season 1