Saving and publishing workflows

You can use the Workflow web service to save and publish workflows. Saving a workflow stores the contents of the workflow on the server, but does not publish it. Publishing a workflow not only stores the contents of the workflow on the server, but validates the workflow and, if valid, makes the workflow available for use.

Saving workflows

Saving a workflow is useful if you are developing a complex workflow, which can go through many revisions prior to publication. You can use one of the following service operations in the Workflow web service to save an exported workflow to SharePoint:

The only difference between SaveFromNWF and SaveFromNWFXml is whether you supply the contents of the export file as a byte array or as a string, respectively. Internally, SaveFromNWF uses SaveFromNWFXml, after converting the byte array to a string.

Overwriting and validating saved workflows

The SaveFromNWF and SaveFromNWFXml service operations, by default, overwrite any existing workflow with the same name for the specified SharePoint site or list. If you do not want to overwrite an existing workflow, you can use the SaveFromNWFNoOverwrite and SaveFromNWFXmlNoOverwrite service operations to save a new workflow from the contents of an export file, specified as either a byte array or string, respectively. Both service operations return an error if an existing workflow is found.

Workflows are not validated when saved. It is possible to save a workflow that contains non-configured workflow actions or other validation issues.

Versioning saved workflows

The minor version of a workflow is incremented each time the workflow is saved, even if the contents of the workflow have not changed. For more information about workflow versions, see Workflow versions.

Publishing workflows

You can use one of the following service operations in the Workflow web service to publish an exported workflow to SharePoint:

As with SaveFromNWF and SaveFromNWFXml, the only difference between PublishFromNWF and PublishFromNWFXml is whether you supply the contents of the export file as a byte array or as a string, respectively. Internally, PublishFromNWF uses PublishFromNWFXml, after converting the byte array to a string.

Note: You must publish site workflows to a SharePoint site and reusable or list workflows to a SharePoint list or document library. If you attempt to publish a site workflow to a SharePoint list or document library, or a reusable or list workflow to a SharePoint site, an error occurs.

Overwriting and validating published workflows

The PublishFromNWF and PublishFromNWFXml service operations, by default, overwrite any existing workflow with the same name for the specified SharePoint site or list. If you do not want to overwrite an existing workflow, you can use the PublishFromNWFNoOverwrite and PublishFromNWFXmlNoOverwrite service operations to publish a new workflow from the contents of an exported workflow, specified as either a byte array or string, respectively. Both methods return an error if an existing workflow is found.

Similarly, the PublishFromNWF and PublishFromNWFXml service operations, by default, validate the workflow prior to publishing it. If a validation error, such as an non-configured workflow action, is encountered, these service operations return an error. If you do not want to validate the workflow, you can use the PublishFromNWFSkipValidation and PublishFromNWFXmlSkipValidation service operations to publish the workflow without validation.

Finally, if you want to neither overwrite an existing workflow, nor validate the workflow prior to publication, you can use the PublishFromNWFSkipValidationNoOverwrite and PublishFromNWFXmlSkipValidationNoOverwrite service operations.

Versioning published workflows

The major version of a workflow version number is incremented each time the workflow is published, even if the contents of the workflow have not changed. For more information about workflow versions, see Workflow versions.

Permissions and approval

The credential used to invoke any of the service operations for publishing a workflow must be a member of the Workflow Designer role in Nintex Workflow 2013. For more information about security settings, see the Nintex Workflow 2013 product documentation.

Example

The following example demonstrates a very simple function that saves a workflow, using the SaveFromNWF service operation, from the contents of an export file.

public bool SaveWorkflowFromFile(string fileName, string workflowName, string listName)
{
    try 
    {              
        // Use the SaveFromNWF service operation to save the contents
        // of the specified file as a workflow to the specified list.
        // If a list isn't specified, the workflow is saved to the current site.
        var workflowMetadata = soapClient.SaveFromNWF(
            File.ReadAllBytes(fileName),
            listName,
            workflowName);

        return true;
    }
    catch 
    {
        // An error occurred while saving the workflow.
        return false;
    }
}

See Also

Concepts

Workflows

Operations

Exporting and importing workflows

Reference

Web Service Reference