Adding and Remove O365 Groups with Nintex Workflow
Recently, I came across a question about using Nintex Forms and Workflow in O365, to create SharePoint Groups.
That’s the kind of challenge I like. Sometihng to wrap my head around to see how something like that could be automated.
A little research and I found that UserGroup.asmx exists in O365 and I can call that. It exposes AddGroup and RemoveGroup web methods, that can be called from a Web Request action in Nintex Workflow.
Before i get into that, I created a simple Nintex Form. The List Template is available to download at the end of this post.
And yep.. I just noticed that for the Option of “Add/Remove, I put in “Create” haha. Oops. Oh well.
The minimum requirements in order to create a Group, are a Group Name, Group Owner and Default User.
The Form has a simple rule to hide the Group Owner and Default Group User if you select “Remove” in the drop down. But it’s a simple one.
Lets have a look at what the workflow looks like:
Essentially I broke up my workflow into a few states in a State Machine. The first being the initial state, which determines if we are creating or removed a group. Then it jumps to the appropriate state. The final state is the one that sends a notification to the initiator with the response from the UserGroup web service.
Both web service calls require an XML (SOAP) body to be put together. So I did that with a Build string action.
Create Group
<?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:Group Name}</groupName>
<ownerIdentifier>{Current Item:Group Owner}</ownerIdentifier>
<ownerType>user</ownerType>
<defaultUserLoginName>{Current Item:Default Group User}</defaultUserLoginName>
<description>Group of {Current Item:Group Name}</description>
</AddGroup>
</soap:Body>
</soap:Envelope>
Remove Group
<?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>
<RemoveGroup xmlns=”http://schemas.microsoft.com/sharepoint/soap/directory/”>
<groupName>{Current Item:Group Name}</groupName>
</RemoveGroup>
</soap:Body>
</soap:Envelope>
I hope this helps.
REMINDER – when you import the workflow, you will need to open both Web Request actions and put in valid credentials that can create groups.