cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JazzyN20
Frequent Visitor

Azure Group Members Sync to SharePoint List

I need to sync an Azure groups members with a SharePoint List, it must have logic to not create an item in the SharePoint list if the member already exists in the list.

It should also be able delete a list item from the list if a user has been removed from the Azure group.

 

My current flow works when testing, the items are created but it throws errors because of unique columns such as email and username.

1 ACCEPTED SOLUTION

Accepted Solutions

@JazzyN20  yea for final solution when list will have 1000 items, you should put a filter query o Group ID

 

So first you will need to identify the users from AD group which are not added to SharePoint list, to do that follow below steps:

1. Add select action after Get Items, and configure it as below screenshot, for From parameter select value (list of items) from Get Items dynamic content and for Map parameter, click on little icon on right of the input box, instead of Title column you can use the column which stores email of user in the list

annajhaveri_0-1616676089599.png

2. Again add select action, and configure it as below screenshot, for From parameter select Group Members from  dynamic content and for Map parameter, click on little icon on right of the input box and select Group Member Mail

annajhaveri_1-1616676802709.png

 

3. Now add filter array action and select the second Select (group members) output in the From parameter, then in left side of value use  join(body('Select'), ';') expression, select does not contain from dropdown and on right side of value user item() expression as shown in below screenshot

annajhaveri_2-1616676943593.png

 

Now you will have array of list of users (email) which are added to AD group but not added to SharePoint list

 

to add the remaining users to the SharePoint list configure apply to each and create item action as below screenshot:

 

annajhaveri_4-1616677408628.png

 

 

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

View solution in original post

12 REPLIES 12
annajhaveri
Super User
Super User

@JazzyN20  i think you need to add Get items action with filter query to first check if user is already added to the list or not.

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

Thanks @annajhaveri but I am already playing around with the get items action, it is more the question of how to get it to all work

@JazzyN20  can you share structure of your SP list (columns and column type). Do you have filter query on Get Items? Also if you can share your existing flow screenshot i can advise how you can take it further?

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

JazzyN20_0-1616603063400.png

I have no filter yet, the list is small so no need to filter but the final solution will have over 1000 items.

I have added a column to my contacts list named 'GroupID', this is for the object ID of the user in the O365 group can be added so I have a shared record in common to perform the conditional check. It is the condition logic that I am struggling with. Thanks

@JazzyN20  yea for final solution when list will have 1000 items, you should put a filter query o Group ID

 

So first you will need to identify the users from AD group which are not added to SharePoint list, to do that follow below steps:

1. Add select action after Get Items, and configure it as below screenshot, for From parameter select value (list of items) from Get Items dynamic content and for Map parameter, click on little icon on right of the input box, instead of Title column you can use the column which stores email of user in the list

annajhaveri_0-1616676089599.png

2. Again add select action, and configure it as below screenshot, for From parameter select Group Members from  dynamic content and for Map parameter, click on little icon on right of the input box and select Group Member Mail

annajhaveri_1-1616676802709.png

 

3. Now add filter array action and select the second Select (group members) output in the From parameter, then in left side of value use  join(body('Select'), ';') expression, select does not contain from dropdown and on right side of value user item() expression as shown in below screenshot

annajhaveri_2-1616676943593.png

 

Now you will have array of list of users (email) which are added to AD group but not added to SharePoint list

 

to add the remaining users to the SharePoint list configure apply to each and create item action as below screenshot:

 

annajhaveri_4-1616677408628.png

 

 

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

View solution in original post

Sorry for the silence, been busy but I will have a look this week and come back to you

Hi Anna

 

I do not see this final option...

JazzyN20_0-1618226600732.png

 

So i typed in the expression 'item()' and hit save. It then populated the filter array value as per you instruction but i know receive this Flow error for the first filter array value you specified of  join(body('Select'), ';')...

 

JazzyN20_0-1618234160456.png

 

Just type in item() in the expression and click on Ok button as shown below 

 

annajhaveri_0-1618234252069.png

 

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.
JazzyN20
Frequent Visitor

Hi Anna

 

I have this working now, thank you.

I do have an issue with the final 'Create Item' action . When using the 'Current Item' value, this only inserts the Email Address from the AD group into my SharePoint List.

The other fields such as 'Contact Name' cannot be accessed. If I use the 'Current Item' value then it inserts the email address value. How do I map these over too?

JazzyN20_0-1618244379552.png

 

I tried simply inputting the AD Group Action get values but this then inserts another Apply to Each branch inside the existing one, when the flow is run it tries to create all of the items - one run for each and every value passed from the array!

 

JazzyN20_1-1618244426550.png

 

@JazzyN20  what is the data type of the Contact Name and the Email address fields, what data you want to save into these fields?

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.
JazzyN20
Frequent Visitor

Anna, I have figured it out now, thanks

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (1,738)