Power Apps,  Power Automate,  Power Platform,  SharePoint Online

Manage SharePoint Group Permissions with Power Automate and Power Apps

Hello there and welcome back! Today we’re going to build a solution to get, search, add and remove users from SharePoint groups. This is going to be a continuation of our previous blog post on how to add or remove users from a SharePoint Group, so be sure to check that out!


Let’s have a look at the case scenario!


We are having X number of SharePoint sites with tons of SharePoint groups in them. Our task is to manage the group members, grant access to new users, as well as remove users that should no longer be part of it. Currently, it’s being done manually and it’s a hassle as we need to traverse through multiple SharePoint sites and groups with many users in them. To make this process easier, we are going to build a Power App to manage all these and back it up with Power Automate flows to perform actions.



 

Note: We are using a SharePoint list as the data source for our Groups, rather than fetching them directly from the SharePoint sites, that’s because when we’re using a list, we have full control over which groups should be manageable through the App and which groups to avoid showing in the app.



Now let’s jump into the solution!


1. All our SP Group details from different sites are stored inside the SharePoint list



2. Now we’ll build our flow with a Power Apps trigger that accepts the following inputs



3. Next We will call our HTTP action to get the SP Group members for a selected group



4. We will then parse the HTTP output using “Parse JSON” action



5. The output member array is generated using the “Select” action



6. The generated output is sent back to the App



7. Now that the flow is ready, we will add it to our app and use it on selection of a Group. The output of the flow is then converted into a collection and stored using the “MatchAll” expression

ClearCollect(colUsers,MatchAll(‘20220305-GetSPGroupMembers’.Run(ThisItem.’Group ID’,ThisItem.Site).data,”\{“”Email””:””(?<Email>[^””]*)””,””Name””:””(?<Name>[^””]*)””,””Id””:(?<Id>[^””]*)\}”))

 



8. The output collection is now used as the “Items” for users’ gallery
Sort(Filter(colUsers, Inp_Search.Text in Name || IsBlank(Inp_Search.Text)), Name ,If(sortAscending, Ascending, Descending))

 



9. Using the flow that we’ve built in the previous blog for this series, we will add or remove users using the following formulas



Remove user:- ‘20220303-AddorRemoveuserfromSharePointgroup’.Run(ThisItem.Email, false, gal_SPGroups.Selected.GroupID, gal_SPGroups.Selected.Site)





Add users:- ‘20220303-AddorRemoveuserfromSharePointgroup’.Run(Left(Concat(dd_users.SelectedItems, Claims & “,”),Len(Concat(dd_users.SelectedItems, Claims & “,”)) -1),true,dd_group.Selected.GroupID, dd_group.Selected.Site);



 

There we go! We’re now able to get, search, add and remove users from any SharePoint Groups across multiple sites without stepping out of the Power App.

 

Hope you found this post helpful. Until Next Time!

10 Comments

  • Josh

    Hi,

    I am having issues with the regex section and noticed that your text and the image both have different text.
    Would you be able to help add some more clarity around the Regex within MatchAll to help me understand how I can get this working.

    Thanks!

    • shaiksha35

      Hi Josh,

      Thanks for pointing it out! I’ve updated it now.

      ClearCollect(colUsers,MatchAll(‘20220305-GetSPGroupMembers’.Run(ThisItem.’Group ID’,ThisItem.Site).data,”\{“”Email””:””(?[^””]*)””,””Name””:””(?[^””]*)””,””Id””:(?[^””]*)\}”))

  • Guna

    Hi Sir,

    why this formula not support to me

    UpdateContext({VarUsers: Inp_Emails.SelectedItems.Claims});’PowerHourAddorRemoveUserfromSPGroup’.Run(Left(Concat(VarUsers, Claims & “;”),Len(Concat(VarUsers, Claims & “;”))-1,true), gal_SPGroups.Selected.’Group ID’, gal_SPGroups.Selected.Site)

  • Guna

    Hi Sir,

    Thank you very much, sir, for this kind of useful and informative video,

    I appreciate your detailed and clear explanations in this video.

    Now I have a requirement. So I look it up online. I cannot find a video that covers the whole topic.

    Basically, what I need is.

    For the end-user to add the multiple Excel files to the document library (subfolder – six stages folder)

    Here is the folder structure in my organization. We manage nine sites.

    AP>FY2022>P12>Parent Comp>Child Comp>Account Folder.
    AR>FY2022>P12>Parent Comp>Child Comp>Account Folder
    Costing>FY2022>P12>Parent Comp>Child Comp>Account Folder.

    Assume the following.
    1. Upload the files to a subfolder
    2. Just view the files in a subfolder (for reviewers) File view screen
    3. Download the documents (for Auditors or for Internal Auditor – Controller)
    4. Document library file upload stage URL (user copies and pastes this SP URL into other ERPs)

    Is it possible to make it power apps.

    Simple requirement – Sub folder access for upload and view and download and URL display copy the Link.

  • Guna

    Hi Sir, Really thanks for your kind support and help, but one major part is mission in that video.
    because each and every time went to share point to check whether Users Name add or deleted, But we need to bring this existing User Name in same apps in right side. so that we avoid to checking Share point.

  • Guna

    Sir, could you please post any video? So many steps and processes. I am not able to do it like that. How to add a button. How to run that formula, if you post a video from scratch. It will be very helpful to learn and make these apps.. kindly help me sir..

    Kindly forgive me to ask tis many question please

  • Guna

    Hi Sir, can we add multiple User names add \ remove them in the same pattern? Because we received multiple User names in the same Group. to add one by one, is there any solution to add the entire User name single shot in Group?

Leave a Reply

Your email address will not be published. Required fields are marked *