TerminateWorkflowByName

Terminates the current instance, and, optionally, previous instances, of the specified site, reusable, or list workflow.

Syntax

public void TerminateWorkflowByName(
	string fileUrl,
	string workflowName,
	bool terminatePreviousInstances
)

Parameters

fileUrl
Type: System.String

Optional. The absolute or relative URL of the file on which to terminate a reusable or list workflow. If a relative URL is specified, the URL must be relative to the current SharePoint website.

To terminate a site workflow, do not specify a value for this parameter.

workflowName
Type: System.String

Optional. The name of the site, reusable, or list workflow.

terminatePreviousInstances
Type: System.Boolean

Required. Indicates whether previous instances of the workflow specified in workflowName should also be terminated. If set to true, the current instance and all previous instances of the specified workflow are terminated; otherwise, only the current instance of the specified workflow is terminated.

Remarks

If a file URL is specified in fileUrl, the method first attempts to retrieve the list item for the specified file URL. If the list item exists, the method then attempts to retrieve existing workflow instances for the list item and the workflow associations for the list that contains the list item; otherwise, an error occurs. If a file URL is not specified in fileUrl, the method attempts to retrieve the existing workflow instances and workflow associations for the current SharePoint website.

The method then iterates through the existing workflow instances. If terminatePreviousInstances is set to true, all existing workflow instances, current and previous, that match the workflow specified in workflowName are terminated; otherwise, only the current existing workflow instance that matches the specified workflow is terminated.

Example

The following example demonstrates how to use this operation to terminate the current instance of a site workflow.

Request

The following SOAP request attempts to terminate only the current instance of a site workflow named TestSiteWorkflow.

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" 
   xmlns:nin="http://nintex.com">
   <soap:Header/>
   <soap:Body>
      <nin:TerminateWorkflowByName>
         <nin:fileUrl />
         <nin:workflowName>TestSiteWorkflow</nin:workflowName>
         <nin:terminatePreviousInstances>0</nin:terminatePreviousInstances>
      </nin:TerminateWorkflowByName>
   </soap:Body>
</soap:Envelope>

Response

The following SOAP response indicates that the workflow instance was successfully terminated.

<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>
      <TerminateWorkflowByNameResponse xmlns="http://nintex.com"/>
   </soap:Body>
</soap:Envelope>

See Also

Concepts

Workflows

Operations

Terminating workflows

Managing workflow execution

Reference

TerminateWorkflow

TerminateWorkflowByNameForListItem

Web Service Reference