Skip to content

[Nintex Workflow] Add user to Site Collection Administrator group with REST API

Helping people to automate their workplace is my passion and lucky for me I also get paid to do so !
This week I was finishing working with a partner to improve the (poor) automation steps required by Matter Center, which no-one can really complain because Microsoft made it open-source.
Matter Center documentation requires to create each client as a new site collection in PowerShell, but this is not quite possible if the users registering these new clients on a daily basis are regular Office 365 users and not SharePoint Administrators.Thanks to a few Nintex Workflows we managed to do all the configuration in the background.
Thanks to a few Nintex Workflows we managed to do all the configuration in the background.
Today’s post is not about the site collection creation so I will spare the details, but in summary and very high level, I developed 4 workflows, 1 CSOM Javascript to be executed on the browser, and 1 Nintex Form of course for submitting the new client on desktop or mobile.
Now this quick blog post is regarding the challenge that we had to add the user as a Site Collection Administrator of that newly created site collection.
Since there is no mention of the sort in https://community.nintex.com it may useful for someone, so here it is:

  1. Create a new Nintex workflow in an Office 365 site list.
  2. Download and Import the .NWP workflow file available here to replace the blank workflow
  3. Edit a few of the actions at the beginning of the workflow to set the variables (I never hard-code UserName and Password for instance, so you will see a few Lookup to a different list to get the value, which you can replace since they will be showing an error once imported into your list)


Note: In this workflow, the “user” I am adding to the Site Collection Administrators group is actually the “CreatedBy” of the list item, which may sound strange since the user running that workflow may be the CreatedBy. However this is NOT the case (refer to above point: we do not want all users to be SharePoint admins!), here is how you should sequence the workflow to start:
1) After the List Item is created, a first workflow (run by CreatedBy) i.e. called “Start and Call workflow 2” and in the workflow we just add a “Start Workflow”
2) then within that first workflow we just add a “Start Workflow” making sure that this action is bein executed in an “App Step” in order to use “elevated privilege”.
Nintex_Workflow_for_Office_365
3) finally all the actions are happening in Workflow2 (which you imported in step 2)
 
Hope this helps someone.
François.