web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Adding O365 Group Memb...
Power Automate
Unanswered

Adding O365 Group Members if they appear in a SharePoint List

(0) ShareShare
ReportReport
Posted on by

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

Categories:
I have the same question (0)
  • VictorIvanidze Profile Picture
    13,073 on at

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

  • Community Power Platform Member Profile Picture
    on at

    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 Profile Picture
    13,073 on at

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

  • Community Power Platform Member Profile Picture
    on at

    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 Profile Picture
    13,073 on at

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

  • Community Power Platform Member Profile Picture
    on at

    Hi Victor,

     

    This is the end of the flow:

    freddiejoseph1_0-1642496216219.png

     

    Thanks,

     

    Freddie

  • VictorIvanidze Profile Picture
    13,073 on at

    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.

  • Verified answer
    Community Power Platform Member Profile Picture
    on at

    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-Adding/td-p/167695:

     

    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

  • Pree Profile Picture
    2 on at

    Hello Freddie, Would you please share your flow? I am getting the same error and looking for soluction. Your guidance will be really appriciated.

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard