StartWorkflowOnListItem

Starts an instance of a reusable or list workflow for the specified list item in the specified SharePoint list, optionally providing association data.

Syntax

public Guid StartWorkflowOnListItem(
	int itemId,
	string listName,
	string workflowName,
	string associationData
)

Parameters

itemId
Type: System.Int32

Required. The identifier of the SharePoint list item.

listName
Type: System.String

Required. The name of the SharePoint list.

workflowName
Type: System.String

Required. The name of the reusable or list workflow.

associationData
Type: System.String

Optional. The association data to use for the reusable or list workflow. If association data is not specified, default values specified for workflow variables in the workflow are used.

Returns

Type: Guid

The identifier of the started workflow instance.

Remarks

The method first attempts to retrieve an existing workflow association between the list specified in listName and the list workflow specified in workflowName. If a workflow association between the 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 any of the content types for the list and the specified workflow does not exist, an error occurs.

If a workflow association can be retrieved, the method attempts to start the reusable or list workflow immediately on the specified list item. If the workflow cannot be started immediately, an error occurs; otherwise, the method returns the identifier of the resulting started workflow instance.

Setting Association Data

The associationData element contains an XML-encoded string, representing an XML fragment. The XML fragment is a single element, named Data, that can contain values for workflow variables defined in the list workflow. For more information about using association data, see Using association data for starting workflows.

Note: You cannot include the Data element within the associationData element without first converting it to an XML-encoded string; otherwise, an error occurs.

Example

The following example demonstrates how to use this operation to start a list workflow on a list item, providing association data.

Request

The following SOAP request starts the TestListWorkflow list workflow on the TestContacts1 list, for the list item with an identifier of 2, and provides association data for two variables:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" 
   xmlns:nin="http://nintex.com">
   <soap:Header/>
   <soap:Body>
      <nin:StartWorkflowOnListItem>
         <nin:itemId>2</nin:itemId>
         <nin:listName>TestContacts1</nin:listName>
         <nin:workflowName>TestListWorkflow</nin:workflowName>
         <nin:associationData>
&lt;Data&gt;
&lt;IntegerVariable&gt;40&lt;/IntegerVariable&gt;
&lt;MultipleLineVariable&gt;MultipleLine Line 1\nMultipleLine Line 2&lt;/MultipleLineVariable&gt;
&lt;/Data&gt;
         </nin:associationData>
      </nin:StartWorkflowOnListItem>
   </soap:Body>
</soap:Envelope>

Response

The following SOAP response returns the identifier of the started workflow instance.

<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>
      <StartWorkflowOnListItemResponse xmlns="http://nintex.com">
         <StartWorkflowOnListItemResult>d6e9ac06-801b-471e-ad88-940683136693</StartWorkflowOnListItemResult>
      </StartWorkflowOnListItemResponse>
   </soap:Body>
</soap:Envelope>

See Also

Concepts

Workflows

Operations

Starting workflows

Managing workflow execution

Reference

StartWorkflowOnListItem

TerminateWorkflow

TerminateWorkflowByName

TerminateWorkflowByNameForListItem

Web Service Reference