TerminateWorkflowByNameForListItem

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

Syntax

public void TerminateWorkflowByNameForListItem(
	string listName,
	int itemId,
	string workflowName,
	bool terminatePreviousInstances
)

Parameters

listName
Type: System.String

Optional. The name of the SharePoint list.

itemId
Type: System.Int32

Required. The identifier of the SharePoint list item.

workflowName
Type: System.String

Optional. The name of the 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

The method first attempts to retrieve the list item specified in itemId for the list specified in listName. If the list item exists, the method then attempts to retrieve the existing workflow association between the specified list and the list workflow specified in workflowName.

If a workflow association between the specified list and the specified workflow exists, then the method iterates through existing instances of the specified list workflow. If terminatePreviousInstances is set to true, all existing workflow instances, current and previous, that match the specified list workflow are terminated; otherwise, only the current existing workflow instance that matches the specified list workflow is terminated.

If a workflow association between the specified list and the specified workflow does not exist, the method then iterates through each content type for the list, attempting to retrieve a workflow association between a content type for the list and the reusable workflow specified in workflowName. If a workflow association between one of the content types for the specified list and the specified reusable workflow exists, the method iterates through existing instances of the specified reusable workflow. If terminatePreviousInstances is set to true, all existing workflow instances, current and previous, that match the specified reusable workflow are terminated; otherwise, only the current existing workflow instance that matches the specified reusable workflow is terminated.

Example

The following example demonstrates how to use this operation to terminate current and previous instances of a list workflow for a list item.

Request

The following SOAP request attempts to terminate current and previous instances of the TestListWorkflow list workflow on the TestContacts1 list, for the list item with an identifier of 2.

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:nin="http://nintex.com">
   <soap:Header/>
   <soap:Body>
      <nin:TerminateWorkflowByNameForListItem>
         <nin:listName>TestContacts1</nin:listName>
         <nin:itemId>2</nin:itemId>
         <nin:workflowName>TestListWorkflow</nin:workflowName>
         <nin:terminatePreviousInstances>1</nin:terminatePreviousInstances>
      </nin:TerminateWorkflowByNameForListItem>
   </soap:Body>
</soap:Envelope>

Response

The following SOAP response indicates that current and previous instances of the list workflow were 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>
      <TerminateWorkflowByNameForListItemResponse xmlns="http://nintex.com"/>
   </soap:Body>
</soap:Envelope>

See Also

Concepts

Workflows

Operations

Terminating workflows

Managing workflow execution

Reference

TerminateWorkflow

TerminateWorkflowByName

Web Service Reference