Creating and deploying a custom full-trust workflow activity to a SharePoint 2010 environment involves the following three key steps:
- Create an activity class that derives from the System.Workflow.ComponentModel.Activity base class and overrides the Execute() method.
- Add an authorizedType entry to the Web.config file for each activity class.
- Create a workflow actions file that defines how the workflow engine and the SharePoint Designer user interface will interact with your activity classes.
The Workflow Activities Reference Implementation (Workflow Activities RI) includes three workflow activities. CreateSiteCollectionActivity creates a new site collection, using parameters supplied by the workflow. CreateSubSiteActivity creates a new site in a site collection, using parameters supplied by the workflow. SiteExistsActivity returns a Boolean value to indicate whether a specified site or site collection already exists at the specified URL.
Within the workflow actions file required for SharePoint Designer support, workflow activities are packaged as actions. You can also define conditions in the workflow actions file. In this solution, CreateSiteCollectionActivity and CreateSubSiteActivity are packaged as actions, and SiteExistsActivity is packaged as a condition.
Unlike actions, conditions are not required to derive from System.Workflow.ComponentModel.Activity. A condition class must declare a method that does the following:
- Returns a Boolean value
- Takes an object of type Microsoft.SharePoint.WorkflowActions.WorkflowContext as its first parameter
- Takes a string, which represents the GUID of the parent list, as its second parameter
- Takes an integer, which is the ID of the parent list item, as its third parameter
|In the case of the SiteExistsActivity, it was decided to implement this as an activity so that the code could be leveraged easily within a full-trust coded workflow as well as a declarative workflow.|