Publish Nintex workflow file to more than one SharePoint lists / libraries using Nintex SDK

Special thanks to Vadim Tabakman (working in Nintex) who gave this idea to develop this reusable tool.

As you know Nintex workflows are easy to build and customize. But, sometimes we have to deploy a common/reusable nintex workflow to more than one lists or document libraries in a site collection. In this case, when we got a requirement to change something in workflow then we will be in trouble like how to publish the new changed workflow to all libraries.

Imagine we have 100 sub sites with 8 lists / document libraries. It means we have to publish the nintex workflow to 100 * 8 = 800 lists and libraries. Which is not at all possible with the manual upload process? So, the only way would be writing code to publish them automatically by running it.

The solution which I have written needs the updated nintex workflow file [.NWF] as input, web url and site url. It loops through all sites in the site collection and updates the each and every library/lists with the updated nintex file successfully.

Below is the code which does that:

private static void UpdateWokflow()


ArrayList chkedlist = new ArrayList(); // To capture the list names where we have import workflow



for (int i = 0; i < chkList.Items.Count; i++)


if (chkList.GetItemChecked(i))





string siteid = ddSitecollection.SelectedValue.ToString();

Guid MyGuid = new Guid(siteid);



SPSite dsite = new SPSite(MyGuid);

SPWeb web = dsite.OpenWeb(ddSubSiteCollcetion.SelectedText.ToString());

web.AllowUnsafeUpdates = true;

byte[] rawData = File.ReadAllBytes(txtFiles.Text + “\\” + ddWFName.SelectedItem.ToString());

NintexWorkflowWS.NintexWorkflowWS ws = new NintexWorkflowWS.NintexWorkflowWS();

ws.Url = web.Url + “/_vti_bin/NintexWorkflow/workflow.asmx”;

ws.UseDefaultCredentials = true;

string workflowname = string.Empty;

foreach (string listName in chkedlist)


if (!chknewwf.Checked) // check to preserve the same name for the workflow or not


workflowname = listName + “-” + ddWFName.SelectedItem.ToString().Split(‘.’)[0] + “Workflow”;




workflowname = listName + “-” + txtnewworkflowname.Text + “Workflow”;


//Publish the workflow

ws.PublishFromNWF(rawData, listName, workflowname, true);


web.AllowUnsafeUpdates = false;




catch (Exception exception)


MessageBox.Show(“An error occured while trying to publish the workflows: ” + exception.Message);



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.