Table of contents
Disclaimer: This method only works if you have a unique property to compare on. In the sample below its the E-Mail.
Setup / example
We will use two arrays:
- A list of members from a group in Entra ID
- A list of items from SharePoint containing users. The list contains two columns called FullName and Account.
For this scenario we will not have more than 999 members in the Entra ID group and not more than 5000 items in the SPO list. The group is our leading table, the Sharepoint list the child.
The SPO list is supposed to be synced with the group members and therefore, updated regularly. That means that we need to check for:
- Group members that are missing from the SharePoint list and need to be added
- Group members that were removed, but are still in the SharePoint list and need to be removed
The flow
We will use the Filter array action to filter out what we needs to be added and what needs to be removed.
To figure out which items need to be added we essentially ask “From the leading table, which item is not in the child table”.
To figure out which items need to be removed we essentially ask “From the child table, which item is not in the leading table.”
Please be aware of the action names I used here, if you simply copy and paste all expressions.
- Create a new flow and choose the trigger you need. In my case I will simple add a manual trigger.
- Add a Get items action and configure it for the site and list you are storing the users in
- In this action navigate to Settings, enable Pagination and enter 5000 into the Threshold box
- Add a Select action. The select action will transform the get items output to a “flat” value list of emails. We will use this and the emails for the comparison. Configure:
- From: outputs('Get_items_-_users')?['body/value']
- Map: item()?['Account/Email']
- Add a List group members action, either after or in parallel to the Get items action.
- Add a second Select action. The select action will transform the list group members output to a “flat” value list of emails. We will use this and the emails for the comparison. Configure:
- From: outputs('List_group_members')?['body/value']
- Map: item()?['mail']
- Next, we will check what items from the group need to be added to the list.
- Add a Filter array action. The filter in easy words: From the list group members, which members email is not in the SharePoint list (from the select action). Configure:
- From: outputs('List_group_members')?['body/value']
- Filter Query: body('Select_-_only_emails_from_list') does not contain item()?['mail']
- Based on the body (result) of that filter, use apply to each and create the item in your list.
- Finally, we will check whats items need to be deleted from the list as the item was removed from the group.
- Add a second Filter array action. The filter easy words: From the SharePoint list, what items exist, but does not exist in the list group members anymore (from select action). Configure:
- From: outputs('Get_items_-_users')?['body/value']
- Filter Query: body('Select_-_only_emails_from_group') does not contain item()?['Account/Email']
- Based on the body (result) of that filter, use apply to each and remove or update the item in your list.
Changelog
Date | Changes |
25.09.2025 | Initial version |
Thanks for reading! 💕