Small Tips and Tricks : Power Platform – Power Automate to add user to specified SharePoint group

fig : Power Automate - High level steps to add user to group
fig : Power Automate - High level steps to add user to group

Hi All,

Greetings for the day!!!

In last couple of article we are discussing about SharePoint online REST APIs for SharePoint groups / users. Continuing with the series, in this article we will discuss – how to add given user to specific group.

If you miss our last few articles related to groups kindly please have a look

Small Tips and Tricks : Power Platform – Power Automate – simple Power Automate to get all site groups of SharePoint online site – https://knowledge-junction.in/2022/10/11/small-tips-and-tricks-power-platform-power-automate-simple-power-automate-to-get-all-site-groups-of-sharepoint-online-site/

Microsoft 365 : SharePoint Online – Get the Group Membership ID from UI / Fetching all the users of SharePoint group using REST API – https://knowledge-junction.in/2022/10/12/small-tips-and-tricks-power-platform-power-automate-simple-power-automate-to-get-site-group-id-from-group-display-name/

Small Tips and Tricks : Power Platform – Power Automate – simple Power Automate to get site group Id from group display name – https://knowledge-junction.in/2022/10/12/small-tips-and-tricks-power-platform-power-automate-simple-power-automate-to-get-site-group-id-from-group-display-name/

Frequently used REST APIs – Part 1 – https://knowledge-junction.in/2022/09/01/frequently-used-rest-apis-part-1/

High level steps

  • From group display name get the group id – GET REST API – _api/web/siteGroups/getByName(‘<GROUP DISPLAY NAME>’) OR _api/web/sitegroups?$filter=LoginName eq ‘<GROUP DISPLAY NAME>’&$select=Id&top=1
  • Call the POST REST API to add user to the given specified group_api/web/sitegroups(⁠GroupID⁠)/users we need to specify the log in name of user in JSON format in body of “Send an HTTP request to SharePoint” action

Power Automate

  • Create “Instant Cloud flow” so that we could test manually
  • Add the Manual trigger action
fig : Power Automate - Instant Cloud flow - Adding given user to group - Manually triggering the flow
fig : Power Automate – Instant Cloud flow – Adding given user to group – Manually triggering the flow
fig : Power Automate - Action "Send an HTTP request to SharePoint" to get the GroupId from group display name
fig : Power Automate – Action “Send an HTTP request to SharePoint” to get the GroupId from group display name
  • Lets use “Compose” action to see the result as
fig : Power Automate - Action "Compose" action to see the result of previous action
fig : Power Automate – Action “Compose” – to see the result of previous action
  • Initialize the variable “GroupId” to store GroupId so that we can use it in our next action to add the user
  • Action – Initialize variable
fig : Power Automate - Action "Initialize variable" to store GroupId
fig : Power Automate – Action “Initialize variable” to store GroupId
  • Next step is to put the “POST” request to add given user to above given group
  • We will use above “GroupId” variable
  • We have REST API – _api/web/sitegroups(‘GroupID’)/users and in body of action “Send an HTTP request to SharePoint” we will specify user claim as as

{
"__metadata":{"type":'SP.User'},
 'LoginName':'i:0#.f|membership|prasham@knowledgejunction1.onmicrosoft.com'
}

fig : Power Automate - "Send an HTTP request to SharePoint" to add user to group
fig : Power Automate – “Send an HTTP request to SharePoint” to add user to group

Complete Power Automate

fig : Power Automate - High level steps to add user to group
fig : Power Automate – High level steps to add user to group
fig : Power Automate - Actions to add user to group
fig : Power Automate – Actions to add user to group
fig : Power Automate - Actions to add user to group
fig : Power Automate – Actions to add user to group

References

Thanks for reading !! If its worth at least reading once, kindly please like and share !!! SHARING IS CARING 🙂

Enjoy the beautiful life !! Have a FUN !! HAVE A SAFE LIFE !! TAKE CARE 🙂

Prasham Sabadra

LIFE IS VERY BEAUTIFUL :) ENJOY THE WHOLE JOURNEY :) Founder of Knowledge Junction and live-beautiful-life.com, Author, Learner, Passionate Techie, avid reader. Certified Professional Workshop Facilitator / Public Speaker. Scrum Foundation Professional certificated. Motivational, Behavioral , Technical speaker. Speaks in various events including SharePoint Saturdays, Boot camps, Collages / Schools, local chapter. Can reach me for Microsoft 365, Azure, DevOps, SharePoint, Teams, Power Platform, JavaScript.

You may also like...

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: