Today, we will see how we can publish a Nintex workflow dynamically through Nintex actions.
Briefly summarizing, we will create a Nintex workflow(a publisher) which will use workflow actions to publish a workflow(let’s call it ‘Project Details’).
Step 1 – Store the ‘Project Details’ workflow in Document Library
To begin, add the workflow, that needs to be published, in a document library. I called this document library ‘NintexWFTemplates’. Please see the screenshot below –
STEP – 2 Query the document library to read .NWF file url
Use ‘Query List’ Action to query ‘NintexWFtemplates’ document library and store the .nwf file name in a workflow variable ‘siteworkflowNWFUrl’.
Last action just gets the .nwf filename and to generate the .nwf full site url use ‘Set Variable’ action as shown below –
Read the value set for ‘SiteworkflowNWFUrl’ as Web URL/NintexWFTemplates/SiteworkflowNWFURL.
Step-3 Read the content of .nwf (which is xml) in a workflow variable
Now, use the ‘Query XML’ action to read the content i.e. xml of .nwf file in a variable ‘wfFile’. See this action below –
Now in the content, replace replace ‘&’, ‘<‘,’>’ characters with & < and > respectively. This is achieved using three ‘Regular expression’ actions shown below –
Ste-4 Publish the workflow
Finally, to publish the worklfow use ‘Call Webservice’ action as shown below –
Nintex provide a webservice _vti_bin/nintexworkflow/workflow.asmx that exposes different methods to perform different tasks, one of them is to publish a nintex workflow. In the above action, ‘PublishFromNWFXml’ webservice method is used to publish a workflow. This method has 4 parameters –
workflowFile – this is the xml content of .nwf file which we stored in ‘wfFile’ Wf variable.
listName – leave it blank for site workflow. We left it blank as the workflow that we are trying to publish ‘Project Details’ is a Site Workflow. If you are publishing a list workflow then mention the list name.
workflowName – pass the workflow name.
saveIfCannotPublish – set it to false as we dont want to save a workflow if it can’t be published somehow.
That’s it !! Save and Publish this workfow and see it in action publishing another workflow.
Leave a Comment