SharePoint Online - Automate Site & Group Creation with Nintex Workflow O365
What
Nintex Workflow for O365 has an action to create a site automatically in SharePoint, but it's functionality is quite limited. You can't create groups and you can't add staff to those groups. This tutorial shows you how to create a Nintex workflow to automate the whole process using SharePoint Web Services.
Even better, we are going to create the ability to automate Site Creation across multiple Site Collections.
If you're looking for a tutorial on how to do this in Nintex Workflow 2010/2013, I've written an article here: SharePoint 2010 - Automate Site & Group Creation with Nintex Workflow 2010
Why
As most SharePoint administrators are aware, it's ALWAYS a bad idea to give staff the ability to create SharePoint sites. They will end up creating them for the wrong purposes, will not maintain them, no retention policies will get assigned to them, etc.
However, you don't want to restrict your users creative freedom. You want to govern it in a manageable way.
In order to keep track of all your SharePoint sites, we need to ensure that when we allow staff to create sites/content, it is being properly tagged with the right information. As long as you are logging & tagging sites with extra data, you can easily govern and manage those sites far into the future.
This tutorial isn't simply how to automate a process that SharePoint already does. It's automating that process while enforcing that users to tag their sites with data that will help you manage SharePoint easier.
We are going to use the example of Project Sites. Project sites have a known lifespan, usually between 1 month & 2 years depending on size. We want to capture that information so the sites don't hang around for too long.
How
There are 6 steps in my workflow, they are:
First: Create a custom list with the following columns (depending on your needs):
1. Set Variables
I created & set the following variables so that the Web Services would run with the correct information:
Site Collection URL - used if you are planning to allow this workflow to create sites on multiple site collections
Site Template - If you want different site templates to be used on different types of sites
2. Create Site
Use the following Nintex Action to create a site and add all the data you will collect from your list: Office 365 Create Site
3. Create Group
Use the following Action to query a Web Service: Web Request
If you're wondering how I figured out what to input, this guide explains how to get SOAP Web Service Information perfectly: https://community.nintex.com/community/tech-blog/blog/2015/01/22/web-request-action-for-o365
Insert these values to create an 'Owners' Group on your Site Collection without access to anything:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<AddGroup xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/"> <groupName>{Current Item:Site Name} Owners</groupName>
<ownerIdentifier>{Current Item:Site Owner}</ownerIdentifier>
<ownerType>user</ownerType>
<defaultUserLoginName>{Current Item:Site Owner}</defaultUserLoginName>
<description>Used to manage permissions on this site: {Variable:Site Collection URL}{Current Item:Site URL}</description>
</AddGroup>
</soap:Body>
</soap:Envelope>
4. Add Group to Site
the hard part...
Now we need to give the group access to your newly created site. Create another Web Request Action.
The picture will explain most things, however, to get the PermissionMask value (a value assigned to a permission level like Contribute,Read Only, etc), you need to run the following Powershell script on your server: SharePoint Online - Retrieve the Permission Mask Values for a Site using Powershell
FYI: For Owner access with Full Control, the permissionMask is always -1.
Once you have that, Insert these values
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<AddPermission xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/">
<objectName>{Current Item:Site Name}</objectName>
<objectType>web</objectType>
<permissionIdentifier>{Current Item:Site Name} Owners</permissionIdentifier>
<permissionType>group</permissionType>
<permissionMask>-1</permissionMask>
</AddPermission>
</soap:Body>
</soap:Envelope>
5. Add Members to Group
You don't need to do this, but if you're feeling keen you can also run a web service to add a user to the newly created group. Same setup as Step 4, just use the following settings:
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<AddUserToGroup xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/">
<groupName>{Current Item:Site Name} Owners</groupName>
<userName></userName>
<userLoginName>{Current Item:Project Manager}</userLoginName>
<userEmail></userEmail>
<userNotes></userNotes>
</AddUserToGroup></soap:Body></soap:Envelope>
6. Send Emails
Of course now you want to send a nice customised email to your user with all the information they need!
Thoughts?
This saves our team so much time, while allowing us to govern site creation and ensure that all sites have metadata tagged against them !
Have you got any cool tricks to help automate governance that you'd like to share?
If you liked this post:
Credit where it's due
Nintex Workflow for O365 has an action to create a site automatically in SharePoint, but it's functionality is quite limited. You can't create groups and you can't add staff to those groups. This tutorial shows you how to create a Nintex workflow to automate the whole process using SharePoint Web Services.
Even better, we are going to create the ability to automate Site Creation across multiple Site Collections.
If you're looking for a tutorial on how to do this in Nintex Workflow 2010/2013, I've written an article here: SharePoint 2010 - Automate Site & Group Creation with Nintex Workflow 2010
Why
As most SharePoint administrators are aware, it's ALWAYS a bad idea to give staff the ability to create SharePoint sites. They will end up creating them for the wrong purposes, will not maintain them, no retention policies will get assigned to them, etc.
However, you don't want to restrict your users creative freedom. You want to govern it in a manageable way.
In order to keep track of all your SharePoint sites, we need to ensure that when we allow staff to create sites/content, it is being properly tagged with the right information. As long as you are logging & tagging sites with extra data, you can easily govern and manage those sites far into the future.
This tutorial isn't simply how to automate a process that SharePoint already does. It's automating that process while enforcing that users to tag their sites with data that will help you manage SharePoint easier.
We are going to use the example of Project Sites. Project sites have a known lifespan, usually between 1 month & 2 years depending on size. We want to capture that information so the sites don't hang around for too long.
How
There are 6 steps in my workflow, they are:
- 1. Set Variables
- 2. Create Site
- 3. Create Group
- 4. Add Group to Site
- 5. Add Members to Group
- 6. Send Emails
First: Create a custom list with the following columns (depending on your needs):
- Project Name
- Site Description
- Site URL
- Site Owner
- Site Type: Project / Team
- Department
- Project Sponsor
- Project Manager
- Project #
- Estimated Completion Date
1. Set Variables
I created & set the following variables so that the Web Services would run with the correct information:
Site Collection URL - used if you are planning to allow this workflow to create sites on multiple site collections
Site Template - If you want different site templates to be used on different types of sites
setting variables based on 'Site Type' (using Switch Action and Set Variable Actions)
Use the following Nintex Action to create a site and add all the data you will collect from your list: Office 365 Create Site
Create Site Settings
3. Create Group
Use the following Action to query a Web Service: Web Request
If you're wondering how I figured out what to input, this guide explains how to get SOAP Web Service Information perfectly: https://community.nintex.com/community/tech-blog/blog/2015/01/22/web-request-action-for-o365
Insert these values to create an 'Owners' Group on your Site Collection without access to anything:
- URL: {Variable:Site Collection URL}_vti_bin/UserGroup.asmx
- Method: SOAP 1.1
- Soap Action: http://schemas.microsoft.com/sharepoint/soap/directory/AddGroup
- Body: Content
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<AddGroup xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/"> <groupName>{Current Item:Site Name} Owners</groupName>
<ownerIdentifier>{Current Item:Site Owner}</ownerIdentifier>
<ownerType>user</ownerType>
<defaultUserLoginName>{Current Item:Site Owner}</defaultUserLoginName>
<description>Used to manage permissions on this site: {Variable:Site Collection URL}{Current Item:Site URL}</description>
</AddGroup>
</soap:Body>
</soap:Envelope>
4. Add Group to Site
the hard part...
Now we need to give the group access to your newly created site. Create another Web Request Action.
The picture will explain most things, however, to get the PermissionMask value (a value assigned to a permission level like Contribute,Read Only, etc), you need to run the following Powershell script on your server: SharePoint Online - Retrieve the Permission Mask Values for a Site using Powershell
FYI: For Owner access with Full Control, the permissionMask is always -1.
Once you have that, Insert these values
- URL: {Variable:Site Collection URL}{Current Item:Site URL}/_vti_bin/permissions.asmx
- Method: SOAP 1.1
- Soap Action: http://schemas.microsoft.com/sharepoint/soap/directory/AddPermission
- Body: Content
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<AddPermission xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/">
<objectName>{Current Item:Site Name}</objectName>
<objectType>web</objectType>
<permissionIdentifier>{Current Item:Site Name} Owners</permissionIdentifier>
<permissionType>group</permissionType>
<permissionMask>-1</permissionMask>
</AddPermission>
</soap:Body>
</soap:Envelope>
Running the AddPermission Web Method through the Permissions.asmx web service
5. Add Members to Group
You don't need to do this, but if you're feeling keen you can also run a web service to add a user to the newly created group. Same setup as Step 4, just use the following settings:
- URL: {Variable:Site Collection URL}{Current Item:Site URL}/_vti_bin/UserGroup.asmx
- Method: SOAP 1.1
- Soap Action: http://schemas.microsoft.com/sharepoint/soap/directory/AddUserToGroup
- Body: Content
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<AddUserToGroup xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/">
<groupName>{Current Item:Site Name} Owners</groupName>
<userName></userName>
<userLoginName>{Current Item:Project Manager}</userLoginName>
<userEmail></userEmail>
<userNotes></userNotes>
</AddUserToGroup></soap:Body></soap:Envelope>
6. Send Emails
Of course now you want to send a nice customised email to your user with all the information they need!
Thoughts?
This saves our team so much time, while allowing us to govern site creation and ensure that all sites have metadata tagged against them !
Have you got any cool tricks to help automate governance that you'd like to share?
If you liked this post:
Credit where it's due
- https://community.nintex.com/community/tech-blog/blog/2015/01/22/web-request-action-for-o365
Comments
Post a Comment