Export (0) Print
Expand All

SPWorkflowManager.StartWorkflow Method (SPListItem, SPWorkflowAssociation, String, Boolean)

Creates and starts a new workflow instance on a specified list item, based on a specified workflow association, with specified event parameters, and optionally indicates whether this workflow is starting automatically or manually.

Namespace:  Microsoft.SharePoint.Workflow
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

public SPWorkflow StartWorkflow(
	SPListItem item,
	SPWorkflowAssociation association,
	string eventData,
	bool isAutoStart
)

Parameters

item
Type: Microsoft.SharePoint.SPListItem

The list item on which to start the workflow instance.

association
Type: Microsoft.SharePoint.Workflow.SPWorkflowAssociation

The workflow association on which to base the new workflow instance.

eventData
Type: System.String

A string that contains event parameters.

isAutoStart
Type: System.Boolean

If the argument is true, then the method tries to start the workflow immediately; if it cannot be started immediately, then the start is deferred and an SPWorkflow object referencing the unstarted workflow is returned. If the argument is false, the method tries to start the workflow immediately; if it cannot be started immediately, then a null reference (Nothing in Visual Basic) is returned.

Return Value

Type: Microsoft.SharePoint.Workflow.SPWorkflow
A new workflow instance or a null reference (Nothing in Visual Basic), depending on the argument to the isAutoStart parameter.

ExceptionCondition
ArgumentNullException

The argument to the item parameter or the association parameter is a null reference (Nothing in Visual Basic).

ArgumentException

The workflow association passed to the association parameter is not compatible with the list item passed to the item parameter. The item might have the wrong content type or belong to the wrong type of list. Or, the content type of the item is derived from the WorkflowTask content type, but the IsDeclarative property of the workflow association is false; only declarative workflows can be started on a task item.

An ArgumentException is also thrown if the workflow association's Enabled property is false.

UnauthorizedAccessException

The current user has insufficient permissions to start the workflow.

SPException

The item is currently locked due to a short term lock or check-out.

This method calls the StartWorkflow(Object, SPWorkflowAssociation, String, SPWorkflowRunOptions) method with itemas object, association, eventData, and SynchronousAllowPostpone if isAutoStart is true, otherwise with Asynchronous.

Show:
© 2015 Microsoft