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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / My first logic app. Ge...
Power Automate
Unanswered

My first logic app. Get group members from Azure AD and put them into a sharepoint list instead of manually downloading users every week :)

(0) ShareShare
ReportReport
Posted on by 13

Hi all,

 

Im trying to build a flow that will get all members from a group in AD and put them into a SharePoint list. 

I have been able to Get the group members, its working. I connect to the list and that is working also. Now Im not sure how to inject changes to the list. I would like to remove users from the list if they are not members of the group anymore and insert new ones if they are not in the list from before.

 

TerjeMonsen_0-1675242517724.png

Hope someone have time to help me getting this flow to work

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,830 Most Valuable Professional on at

    Hi @TerjeMonsen,

     

    I would suggest to have a look at the except method described by @DamoBird365 in one of his blogs:

    https://www.damobird365.com/efficien-union-except-and-intersect-great-method/

     

    Within this approach you could use the outputs of the two actions a filter if an item is not available.

     

    Below is an example of that approach for your setup

     

    1. Switch both Map fields to text mode with the button on the right side. This makes it easier to compare

     

    2. Add two Filter Array actions. The first one will check for new group members. The second one will check which ones have been removed.

     

    Below are the expressions

     

    From - New group members

     

    body('Select_Email_from_Group_Members')

     

     

    Criteria - New group members

     

    @not(contains(body('Select_Email_from_SharePoint_List'), item()))

     

     

    From - Missing group members

     

    body('Select_Email_from_SharePoint_List')

     

     

    Criteria - Missing group members

     

    @not(contains(body('Select_Email_from_Group_Members'), item()))

     

     

     

    filterarray_except_example.png

     

    Alternatively, you could just delete all items from the list and just add the group members to the list. That would also work. Unless you have a specific requirement to keep track of changes and history.

  • TerjeMonsen Profile Picture
    13 on at

    Ok I have found out how to delete all rows in the SharePoint List. How do I add all again?

     

    TerjeMonsen_0-1675259559843.png

    to the list

  • Expiscornovus Profile Picture
    33,830 Most Valuable Professional on at

    Hi @TerjeMonsen,

     

    Use a second apply to each and loop through the Group Members collection. For each item within that collection create a new list item with the Create Item action.

  • TerjeMonsen Profile Picture
    13 on at

    Thanks one million, It works now 🙂

  • TerjeMonsen Profile Picture
    13 on at

    Ahh another problem, It only gets the first 100 rows both in delete and add

    TerjeMonsen_1-1675275089394.png

     

     

    How can I get it to remove all and add all? The Group has about 800 users

  • Expiscornovus Profile Picture
    33,830 Most Valuable Professional on at

    Hi @TerjeMonsen,


    Can you set the Top count field of the Get items action to 1000? If that does not work can you also enable pagination in the settings of the action:

    https://sharepoint.stackexchange.com/questions/303692/what-is-the-default-number-of-items-that-are-retrieved-in-the-get-items-action-a

     

    Same for the Get Group Members field. By default it will return 100 items. There is a Top field (under advanced options) which you can use and also Pagination.

     

    Btw, if your data sets will get larger, over 5000 items I would suggest to look into Batch methods instead:

    https://www.tachytelic.net/2021/06/power-automate-delete-sharepoint-items/

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 608

#2
Valantis Profile Picture

Valantis 416

#3
11manish Profile Picture

11manish 348

Last 30 days Overall leaderboard