How to: troubleshoot import of a Nintex 2010 Workflow (or, how to programmatically import it)

Have you ever tried to import a Nintex workflow through the user interface (U.I), but failed? In such case, unfortunately, the U.I will not provide you with any error messages, or warnings of any kind.

So, how do you import a workflow that you know is valid and working?

Along with Nintex Workflow, you get a bunch of Nintex Web Services that you can use to programmatically perform tasks that you’d normally do via the U.I.

In order to import a workflow programmatically, you will need to work out something like this (the following is a simple Windows Forms application, this code goes into a button event):

try
{

NintexWorkflowService.NintexWorkflowWS objWFService = new NintexWorkflowService.NintexWorkflowWS();
objWFService.Url = “http://webapp:portNumber/_vti_bin/nintexworkflow/workflow.asmx”;
objWFService.Credentials = System.Net.CredentialCache.DefaultCredentials;
byte[] arrWorkflowFile = System.IO.File.ReadAllBytes(“nameOfExportedWorkflow.nwf”);
objWFService.PublishFromNWFSkipValidation(arrWorkflowFile, “nameOfListOrLibrary”, “desiredNameOfWorkflow”, true);
MessageBox.Show(“Done”);
}
catch (Exception exception)
{
MessageBox.Show(“An error occured while trying to publish the workflows: ” + exception.Message);
}

For this to work, you will need to add a service reference to the Nintex Web Service. Right click on the name of your project, click “Add service reference”, click “Advanced”, click “Add Web Reference” and add the following in the URL field (replacing with your own values):

http://webapp/sitecollection/_vti_bin/nintexworkflow/workflow.asmx

If you got the URL correctly, you will notice a list of operations that you can use. Make sure you rename the web reference (use the field ‘Web reference name’ on the right) to NintexWorkflowService (otherwise, change the code above to match the name you enter in this field).

Make sure you change the placeholders to the correct values in the code above (nameOfExportedWorkflow.nwf, nameOfListOrLibrary, desiredNameOfWorkflow, etc.)

This way, if the workflow fails to import, you will get the error message in a message box. It should be easier to troubleshoot then.

Click here for the application.

The above application allows you to browse for the exported NWF file, define the site collection to import to, the list or library to use and the name by which the workflow will be imported to the site collection

MGR: the Intelogist

About MGR: the Intelogist

SharePoint Server developer, turned Sitefinity developer, turned Angular developer, turned SharePoint Online consultant, turned Unily consultant, turned O365 consultant... Never a dull moment!

Leave a Reply

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

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

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