共用方式為


SPWorkflowManager.StartWorkflow Method (SPListItem, SPWorkflowAssociation, String)

Creates and starts a new workflow instance on a specified list item, based on a specified workflow association, with specified event parameters.

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

Syntax

'Declaration
Public Function StartWorkflow ( _
    item As SPListItem, _
    association As SPWorkflowAssociation, _
    eventData As String _
) As SPWorkflow
'Usage
Dim instance As SPWorkflowManager
Dim item As SPListItem
Dim association As SPWorkflowAssociation
Dim eventData As String
Dim returnValue As SPWorkflow

returnValue = instance.StartWorkflow(item, _
    association, eventData)
public SPWorkflow StartWorkflow(
    SPListItem item,
    SPWorkflowAssociation association,
    string eventData
)

Parameters

  • eventData
    Type: System.String

    A string that contains event parameters.

Return Value

Type: Microsoft.SharePoint.Workflow.SPWorkflow
If the workflow can be started immediately, the method returns a new workflow instance. If it cannot be started immediately, then the method returns a null reference (Nothing in Visual Basic).

Exceptions

Exception Condition
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.

Remarks

This method calls the StartWorkflow(SPListItem, SPWorkflowAssociation, String, Boolean) method with item, association, eventData, true.

See Also

Reference

SPWorkflowManager Class

SPWorkflowManager Members

StartWorkflow Overload

Microsoft.SharePoint.Workflow Namespace

Other Resources

Workflows in SharePoint Foundation

Workflow Development for SharePoint Foundation

Workflow Object Model Overview in SharePoint Foundation