Check If Person Has Been Selected in Person or Group Field Using Microsoft FLOW


Consider a scenario where a requester needs to select multiple users in a people picker field, and you need to check which users have been selected; accordingly you need to take some action if specific user is selected or not. How to achieve this using FLOW? When a requester submits the request, i.e. when  a new item gets created in SharePoint list, you might run a FLOW to validate and take the necessary action.
If you use condition action as shown below then it won’t work – ColumnName contains "user email ID" – it will always return false output


So, what is the correct way to achieve this? There are two ways using which we can achieve this.
First: converting selected users into an array and then filtering the array to check if user is present or not.
Second: Using Resolve Person action and Condition action with contains clause.
Let’s check these one by one. First solution is to generate array of users and filter the array. For demonstration purposes I have manually created a  trigger button FLOW, I have fetched one of the test SharePoint list items which have Person or Group column “InformUsers”.
This is the test SharePoint list item with InformUsers column and value in it
We need to use "Select" and "Filter array" actions as shown below >> You will find these actions under Data Operations category.
We will generate an array of users in Person or Group field >> As shown below add Select action >> In From field add your Person or group field from Get Item action output, in my case its “InformUsers” column
In Map section you need to specify key name, e.g. EmailID, and in the value section select InformUsers Email as shown below >> So we are making array of email IDs of all selected users.
Use Filter Array action to filter the array with user email you are looking for >> As shown below use Output of Select action in From field >> in comparision section on the left side use expression to add
Use “is equal to” operator >> on the value section put email ID which you want to validate >> This action will filter the array with email id you have provided, if it matches the array count will be 1 if it doesn’t match then Filter array count will be 0.
Now add Condition action to check length of Filter array, is it 0 or 1. If it's 0 that means the user you were looking for is not present in the person or group field. If it's not 0 that means the user has been selected in Person or group field.
Use this expression to get length of filter array (output of above action) -
That’s it, run the FLOW and test it. Add the actions in respective Yes or No section depending upon your requirement.
Check out the next blog here, where I have explained the other approach of using Resolve Person action to validate if user has been selected or not.
Thanks for reading, hope this helps.

Similar Articles