Recently, we had a client with a requirement to have a new SharePoint Team Site created, and then have a Nintex Workflow automatically provisioned.
There are a few ways to do this – via Nintex itself (!) – or using C# code.
The scenario I was dealing with was :
- Custom/3rd-Party CRM system
- On creation of new customer, need to provision a ‘client site’ in SharePoint
- Deploy the NWF as an artifact – we deployed to _LAYOUTS/Company/MyWF.NWF
- Created a Web Service that did the SharePoint magic
- A few lines of code to provision the workflow
Here’s what you need to do – within a Visual Studio project :
- Add a reference to the Nintex Workflow “web service”
- /_vti_bin/nintexworkflow/workflow.asmx
- Can then reference the class/project within C# code (NintexWorkflowWS)
- Read in the contents of the NWF (full XML) – and push/deploy to a list/library
The code steps are as follows…
(1) Add a reference to the Web Service
** NB. uses an SPWeb context – created a few steps earlier
var webServiceUrl = currentWeb.Url;
webServiceUrl += "_vti_bin/nintexworkflow/workflow.asmx";
NintexWorkflowWS wsNW = new NintexWorkflowWS();
wsNW.Url = webServiceUrl;
wsNW.UseDefaultCredentials = true;
(2) Get the contents of the Nintex Workflow (NWF)
var pathNWF = “Microsoft SharedWeb Server Extensions14TEMPLATELAYOUTSCompanyMyWF.nwf”
//get the Program Files folder
var fileName = Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles) + pathNWF;
var contentsNWF = System.IO.File.ReadAllText(fileName);
(3) Deploy the NWF onto the list/library
//call the method to publish the workflow
wsNW.PublishFromNWFXml(nwf, “MyDocLibrary”, “Workflow Title”, true);
============================================
That’s essentially it. You just have to call the above method – and it will deploy your workflow.
There’s a bunch of methods within the Nintex Web Service API – the above example uses this method (WSDL) :
There are a bunch of other methods – including “ExportWorkflow” – meaning that you could create a utility/program that cycles through all SPWeb’s – and SPList’s – and then exports to a file.
(I haven’t tried it – I might have to do that next….)
Hope that helps someone – happy Nintex’ing…!
Hmm… This is quite interesting. I’m wondering if this can be powershelled up to help with our deployment process at work (currently involves manually exporting/importing NWFs). Cheers Wookie!
LikeLike
Thanks to VADIM for a reply via Twitter – mentioning how to do in PowerShell… http://www.vadimtabakman.com/nintex-workflow-powershell-find-all-workflows-and-export-or-republish-part-3.aspx
LikeLike
Hey this is somewhat of off topic but I was wanting to know if blogs use
WYSIWYG editors or if you have to manually code with HTML.
I’m starting a blog soon but have no coding experience so I wanted to get guidance from someone with experience. Any help would be enormously appreciated!
LikeLike