“I need to find a user by his job title but Power Automate keeps asking for email or id, how can I use his role property instead?”
When you’re looking for more information about a user, you probably use the ‘Get user profile’ action. You input the user email or his id, and it’ll return his whole user profile. But what if you don’t have his email nor user id? What if you’ve got e.g. his job title, or a unique user code in your organisation? How do you find such user?
Use an HTTP request via Graph API
Since the default action won’t help (unless you want to get all users and then filter with the ‘Filter array’ action) you’ll have to look elsewhere. And the place to look is an HTTP request.
You’re looking for a user, meaning the endpoint to call is /users.
But such request would give you all the users, you don’t want that. You want only the users that fit a condition, a filter in the format below:
https://graph.microsoft.com/v1.0/users?$filter=<property> eq '<value>'
While you might be tempted to use this request in the Office 365 Users action ‘Send an HTTP request’, don’t. At the time of this article it’s not working.
Use the ‘Send an HTTP request’ action from the Office 365 Groups instead.
The response will be a JSON with all the users fitting the condition where you can extract the information directly with an expression.
When an action won’t help, use an HTTP request. While Power Automate has an action to get user profile, you can’t use it to find users using a different property than email or id. Luckily there’s a workaround by adding the filter directly into a request to Graph API. Add the $filter parameter, pick which property it should search in, and the value to look for.