cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Adding O365 Group Members if they appear in a SharePoint List

Hi all,

 

I have built a recurring flow which gets items from a SharePoint list and passes a person column through the Search for Users V2 function to obtain their UPN. I then add these UPNs to the group using the Add Member To Group function and it works great.

 

However, once users have been added to the group, the next time the flow runs it will fail for all of the entries where the UPN already appears in the group. This is expected behaviour, and it still adds someone who isn't a member of the group but appears in the SP List.

 

I was just wondering: what is the best/easiest way of filtering out users who are already a member of the group so that the flow doesn't fail every time it runs? I think I need some kind of lookup which looks up to see if the UPN which is found in the SP List already appears in the group. If yes then it skips that user, if no then it adds that user, and it does that for the whole list.

 

This is what my flow currently looks like: 

freddiejoseph1_0-1642424863031.png

 

When the flow fails this is where it fails:

freddiejoseph1_1-1642425165993.png

 

And the error I get is this: 

"statusCode":400,"headers":{"Transfer-Encoding":"chunked","Vary":"Accept-Encoding","Strict-Transport-Security":"max-age=31536000","request-id":"53839ad3-8a5c-4234-9f44-e74fa003e1f2","client-request-id":"53839ad3-8a5c-4234-9f44-e74fa003e1f2","x-ms-ags-diagnostic":"{\"ServerInfo\":{\"DataCenter\":\"West Europe\",\"Slice\":\"E\",\"Ring\":\"5\",\"ScaleUnit\":\"003\",\"RoleInstance\":\"AM1PEPF0000EEC6\"}}","x-ms-resource-unit":"1","Timing-Allow-Origin":"*","x-ms-apihub-cached-response":"true","Cache-Control":"no-cache","Date":"Mon, 17 Jan 2022 12:50:02 GMT","Content-Type":"application/json","Content-Length":"371"},"body":{"error":{"code":"Request_BadRequest","message":"One or more added object references already exist for the following modified properties: 'members'.","innerError":{"date":"2022-01-17T12:50:03","request-id":"53839ad3-8a5c-4234-9f44-e74fa003e1f2","client-request-id":"53839ad3-8a5c-4234-9f44-e74fa003e1f2"}}}}

 

Any help would be much appreciated,

 

Thanks,

 

Freddie

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Thanks again for coming back Victor. I see what you mean now. That unfortunately didn't solve my issue, the flow still failed at the Apply to Each part, it just moved onto the initialise variable stage which made it show as being successful. 

 

Someone called 'bottekott' has fixed the issue using their method in this thread here: https://powerusers.microsoft.com/t5/Building-Flows/Office-365-Groups-Check-If-Member-Exists-Before-A...

 

  1. Trigger: when an item is created or modified
  2. Action: Initialize a string variable "GroupMembers"
  3. Action: "list group members"
  4. Apply to each "value" from previous step
    1. Action: "Append to string variable"
      1. Name = variable you created in step 2
      2. Value = mail;
  5. Add condition
    1. if "GroupMembers" does not contain "email-value from sharepoint list item"
    2. If yes. Add member to group action
    3. If no, empty

 

I have implemented it on my solution and it works well.

 

Thanks,

 

Freddie

View solution in original post

8 REPLIES 8
VictorIvanidze
Community Champion
Community Champion

Just use "run after" feature - see https://creospark.com/configure-run-after-in-microsoft-power-automate

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.
Anonymous
Not applicable

Hi Victor,

 

I don't think this will help me. If I configure run after 'success' then the flow doesn't add any missing people to the group. And if I configure run after failure then the flow runs as normal but still shows as failing every time there is a user which appears in the SP list and is already in the group.

 

Am I missing something?

 

Thanks,

 

Freddie

VictorIvanidze
Community Champion
Community Champion

Just try - check all 4 options in "run after" and test.

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.
Anonymous
Not applicable

Hi Victor,

 

I have checked and I still get the same failure reason as before using the run after feature.

 

freddiejoseph1_0-1642435022692.png

 

{"statusCode":400,"headers":{"Transfer-Encoding":"chunked","Vary":"Accept-Encoding","Strict-Transport-Security":"max-age=31536000","request-id":"b43fe3a6-db9c-4752-8277-8eb4859ef70a","client-request-id":"b43fe3a6-db9c-4752-8277-8eb4859ef70a","x-ms-ags-diagnostic":"{\"ServerInfo\":{\"DataCenter\":\"West Europe\",\"Slice\":\"E\",\"Ring\":\"5\",\"ScaleUnit\":\"000\",\"RoleInstance\":\"AM1PEPF0000EE99\"}}","x-ms-resource-unit":"1","Timing-Allow-Origin":"*","x-ms-apihub-cached-response":"false","Cache-Control":"no-cache","Date":"Mon, 17 Jan 2022 15:53:32 GMT","Content-Type":"application/json","Content-Length":"371"},"body":{"error":{"code":"Request_BadRequest","message":"One or more added object references already exist for the following modified properties: 'members'.","innerError":{"date":"2022-01-17T15:53:33","request-id":"b43fe3a6-db9c-4752-8277-8eb4859ef70a","client-request-id":"b43fe3a6-db9c-4752-8277-8eb4859ef70a"}}}}

 

Thanks,

 

Freddie

VictorIvanidze
Community Champion
Community Champion

Could you you show a picture where the next block is visible?

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.
Anonymous
Not applicable

Hi Victor,

 

This is the end of the flow:

freddiejoseph1_0-1642496216219.png

 

Thanks,

 

Freddie

It means you have placed "run after" to a wrong place.

Add any "fake" action - for example "set variable" one after "Add members to group 2" and add  "run after" there.

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.
Anonymous
Not applicable

Thanks again for coming back Victor. I see what you mean now. That unfortunately didn't solve my issue, the flow still failed at the Apply to Each part, it just moved onto the initialise variable stage which made it show as being successful. 

 

Someone called 'bottekott' has fixed the issue using their method in this thread here: https://powerusers.microsoft.com/t5/Building-Flows/Office-365-Groups-Check-If-Member-Exists-Before-A...

 

  1. Trigger: when an item is created or modified
  2. Action: Initialize a string variable "GroupMembers"
  3. Action: "list group members"
  4. Apply to each "value" from previous step
    1. Action: "Append to string variable"
      1. Name = variable you created in step 2
      2. Value = mail;
  5. Add condition
    1. if "GroupMembers" does not contain "email-value from sharepoint list item"
    2. If yes. Add member to group action
    3. If no, empty

 

I have implemented it on my solution and it works well.

 

Thanks,

 

Freddie

Helpful resources

Announcements
Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (2,648)