I’m working on a Power Automate flow where I use the Search for Users (V2) action from the Office 365 Users connector. The flow is designed to trigger a condition based on whether any users are found or not.
Here’s the breakdown of the issue:
- I have a form response that collects a name.
- The flow searches for this name using the Search for Users (V2) action.
- If no users are found, I want to send an email notification saying “No user found.”
- If a user is found, I want to send an email saying “User found.”
I’ve tried the following expressions to check whether the Search for Users (V2) action returns any users or not, but the condition is always skipped when no user is found, and it doesn’t trigger the “No user found” path as expected.
Here’s my current condition:
{
"type": "If",
"expression": {
"equals": [
"@empty(outputs('Search_for_users_(V2)')?['body/value'])",
true
]
}
}
Tried different conditions, like:
Checking if the value of the Search for Users (V2) DisplayName is equal with the name from the form response:
"equals": [
"@outputs('Search_for_users_(V2)')?['body/value'][0]['DisplayName']",
"@body('Get_response_details')?['r36d1183edc07456a8f4884f388900d63']"
Also tried combining with other expressions using or, such as:
"or": [
{
"equals": [
"@empty(outputs('Search_for_users_(V2)')?['body/value'])",
true
]
},
{
"equals": [
"@empty(outputs('Search_for_users_(V2)')?['body/value'])",
""
]
}
]
None of these approaches worked. The flow skips the “No user found” action when no user is present, and I don’t get any notification.
Expected Behavior:
- If no users are found, the flow should trigger the “No user found” email.
- If a user is found, the flow should trigger the “User found” email.
Actual Behavior:
- When no user is found, the condition is skipped, and I get no notification at all.
What am I missing? How can I check if no users were found using the Search for Users (V2) action in Power Automate?
Any help is appreciated! Thanks in advance!