Thursday, November 4, 2010

Initiation Form Processing

Initiation Form Processing


--------------------------------------------------------------------------------



When a user starts a workflow on a specific item, SharePoint Foundation examines the InstantiationURL attribute of the Workflow element, in the workflow template definition, to determine the proper form to load.



SharePoint Foundation loads the specified form, passing to it the following query parameters in the URL:



List The GUID of the list to which the item belongs.



ID The ID of the list item on which the workflow is started.



Source The page from which the user started the workflow.



TemplateID The GUID of the workflow association.



In addition, you can program your form to load the association form data for this workflow association. This information is contained in the AssociationData property of the SPWorkflowAssociation object that represents the workflow association.



The workflow developer must program what happens when the user submits changes to the page. In general, the form must perform the following actions:



Locate the SPWorkflowManager object for the current site.



Use the SPWorkflowManager object to invoke the StartWorkflow method, passing the appropriate SPListItem and SPWorkflowAssociation objects. Use the eventData parameter to pass the initiation form data in string format.



Return the user to the source page from which he or she started the workflow.



When the M:Microsoft.SharePoint.Workflow.SPWorkflowManager.StartWorkflow(Microsoft.SharePoint.SPListItem,Microsoft.SharePoint.Workflow.SPWorkflowAssociation,System.String) method is called, the workflow manager creates an instance of the workflow on the SharePoint item. The workflow manager then passes the data gathered using the initiation form to the OnWorkflowActivated event of the workflow itself.



Any SharePoint Foundation workflow must start with an OnWorkflowActivated activity. The OnWorkflowActivated activity contains a property, WorkflowProperties, that returns an SPWorkflowActivationProperties object. This object represents the initial properties of the workflow as it starts, such as the user who added the workflow and the list and item to which the workflow was added. In addition, the AssociationData property returns a System.Collections.Hashtable object that represents the custom data provided by the workflow initiation form.

1 comment: