Nintex Workflow – Create Site with a Dynamic Site Template

The Create Site action in Nintex Workflow is a great action and you can create a site based off a site template.  The Site Template can be selected at design time.  But there are certain situations where you don’t know the template at design time.

The way to do it would be via a web service call to Sites.asmx.  This web service has a CreateWeb web method.

This method, as you can see by following the link, is not well documented.  The parameters it takes are quite straightforward. The only “gotcha” is the template.  This parameter takes an internal template name and not the title that you see when you choose to create a site manually.  So we need to find a way to get the internal name from the title.

Solution

If we can get this to work, this is ideal for a reusable piece of workflow logic.  It just screams of a User Defined Action. 

Firstly, we need to figure out a solution for getting the template internal name from a title.

Again, we can look at the Sites.asmx web service.  It has a method named GetSiteTemplates. The interesting thing with this method is that the method returns an unsigned int.  What we need, is the actual data, but that is returned as an out parameter.  So in order to get this information, rather than using a Call Web Service action, we need something a little more low level.  In this case, we can use the Web Request action.

Web Request

We’ve configured this specifically for English (LCID = 1033).

Finally, based on a Template title, we need to pull out the name.  We do this with Query XML by querying the XML returned from the web request.

The XPath looks like this: //defaultNS:TemplateList/defaultNS:Template[@Title=”{WorkflowVariable:Site Template Title}”]/@Name

The “Site Template Title” will be a variable that we pass in.  This makes this call dynamic.

Finally, we need to make the call to the Sites.asmx web service and call CreateWeb.

Call Web Service

The workflow to test this out is quite simple.  Just fill in some details.

Workflow

Finally, what we need to make sure, is that the User Defined Action has minimal chance of break.  So I put in a bunch of error checking and also a couple of output parameters that when a workflow calls this action, you can store the output results and build your workflow around it.

UDA Call

Downloads

Nintex Workflow 2010 : v2.3.5.0

Download the Create Site with Template Workflow

Download the Create Site with Template (UDA format)

Download the Create Site with Template (NWF format)

Leave a Reply

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