Workflow Initiation in SharePoint Foundation

Applies to: SharePoint Foundation 2010

All Microsoft SharePoint Foundation workflows must start with the OnWorkflowActivated activity. This activity initializes the correlation between the workflow instance and the correlation token, so that the Windows Workflow Foundation (WF) runtime can correctly direct incoming messages to this workflow instance. Each new SharePoint workflow application project you create contains an OnWorkflowActivated activity as the first activity by default.

Using the Information in the OnWorkflowActivated Activity

When a SharePoint Foundation workflow is initiated, the WorkflowProperties property of the OnWorkflowActivated activity returns an SPWorkflowActivationProperties object that represents the initial properties of the workflow as it starts, such as the user who initiated the workflow, and the list and item to which the workflow was initiated. Any activity that needs access to the initiation data of the workflow, such as the workflow ID, can refer to the SPWorkflowActivationProperties object variable specified in the OnWorkflowActivated activity.

You can use the initiation properties from any other activity within the workflow, and they are especially useful when you are using a Code activity to manipulate the SharePoint Foundation item on which the workflow is running.

For more information about the Windows Workflow Foundation, including how to use the Microsoft Visual Studio 2010 Workflow Designer to create workflow solutions, visit the Windows Workflow Foundation Developer Center.

Setting the Properties of the OnWorkflowActivated Activity

When you open a new SharePoint workflow application project, an OnWorkflowActivated activity is the first activity by default, and its required properties are defined by default. Open the Properties window to view the properties for the selected activity.

See Also

Concepts

Workflow Activities for SharePoint Foundation

How SharePoint Foundation Processes Workflow Activities

Correlation Tokens in Workflows