PublishFromNWF
Publishes a new or existing workflow from the contents of a Nintex Workflow workflow (.nwf) file, specified as a byte array.
Syntax
public bool PublishFromNWF( byte[] workflowFile, string listName, string workflowName, bool saveIfCannotPublish )
Parameters
- workflowFile
- Type: System.Byte
Optional. A Base64-encoded byte array, representing the contents of a Nintex Workflow workflow (.nwf) file.
- listName
- Type: System.String
Optional. The name of a SharePoint list. If a value is not specified, the workflow is saved as a site workflow; otherwise, the workflow is saved to the specified list as a list workflow.
- workflowName
- Type: System.String
Optional. The name of the workflow to be saved. If a value is not specified, the name specified in the contents of the Nintex Workflow 2013 export (.nwf) file is used; otherwise, the specified name is used.
- saveIfCannotPublish
- Type: System.Boolean
Required. Set to true to save the workflow if validation errors prevent publishing the workflow; otherwise, set to false.
Returns
Type: Boolean
true if the workflow is successfully published; otherwise, false.
Remarks
A Nintex Workflow workflow (.nwf) file is an XML file created by exporting an existing workflow from the Nintex Workflow designer. For more information about export files, see Export files.
This method cannot convert list workflows to site workflows, or site workflows to list workflows. If the export file contains the definition for a reusable or list workflow, you must publish it to a SharePoint list. If the export file contains the definition for a site workflow, you must publish it to a SharePoint site. Otherwise, an error occurs.
This method first validates the workflow prior to publication. If a workflow with the same name already exists, this method then overwrites and publishes the existing workflow, updating version-specific workflow metadata accordingly. Otherwise, this method then creates and publishes a new workflow.
If you want to skip validation or prevent overwriting an existing workflow, the following related methods are available:
-
Use the PublishFromNWFSkipValidation method if you want to skip validation and overwrite an existing workflow.
-
Use the PublishFromNWFNoOverwrite method if you want to validate the workflow and prevent overwriting an existing workflow.
-
Use the PublishFromNWFSkipValidationNoOverwrite method if you want to skip validation and prevent overwriting an existing workflow.
This method publishes a workflow, optionally attempting to save the workflow only if an error occurs during validation or publication and the saveIfCannotPublish parameter is set to true. To save a workflow directly from the contents of a export file, without publishing the workflow, you can use the SaveFromNWF method, or any of the related methods.
Example
The following example demonstrates how to use this operation to publish a workflow from the contents of a export file.
Request
The following SOAP request attempts to publish a workflow named PublishedWorkflow, defined from the contents of a export file, to the TestContacts2 list, optionally saving the workflow if it cannot be published.
Note: A portion of the value for the workflowFile element has been removed for readability.
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:nin="http://nintex.com"> <soap:Header/> <soap:Body> <nin:PublishFromNWF> <nin:workflowFile> PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48RXhwb3J0ZWRXb3JrZmxvd1dp dGhMaXN0TWV0ZGF0YSB4bWxuczp4c2Q9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1h ... cnRlZFdvcmtmbG93V2l0aExpc3RNZXRkYXRhPg== </nin:workflowFile> <nin:listName>TestContacts2</nin:listName> <nin:workflowName>PublishedWorkflow</nin:workflowName> <nin:saveIfCannotPublish>true</nin:saveIfCannotPublish> </nin:PublishFromNWF> </soap:Body> </soap:Envelope>
Response
The following SOAP response indicates that the workflow was successfully published.
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <PublishFromNWFResponse xmlns="http://nintex.com"> <PublishFromNWFResult>true</PublishFromNWFResult> </PublishFromNWFResponse> </soap:Body> </soap:Envelope>
See Also
Concepts
Operations
Exporting and importing workflows