Consuming Custom Components from a Declarative Workflow

The Workflow Activities Reference Implementation includes a declarative workflow named Create Project Site. The workflow is associated with the Estimate content type, which was created by the Sandbox Reference Implementation. The Estimate content type defines several fields, as shown in the following illustration.

Estimate content type fields

Ff798438.69222ace-deaf-4667-bd4a-a74b4a943bb5(en-us,PandP.10).png

The Create Project Site workflow uses the values of the SOW Status field and the Projects Lookup field on each estimate item during workflow execution. The workflow also defines two local variables, ProjectName and ProjectSiteUrl, to manage the information that is passed to individual workflow actions.

The following illustration shows the sentence designer for the Create Project Site workflow in SharePoint Designer.

Ff798438.note(en-us,PandP.10).gifNote:
In the illustration, the line that begins "Create subsite…" has been cut down because of width restrictions.

Workflow designer for the Create Project Site workflow

Ff798438.47ca49ec-13e7-490e-a643-4bb87badd199(en-us,PandP.10).png

As you can see, the workflow begins with a Wait for Field Change in Current Item action. This pauses the execution of the workflow until the SOW Status field of the current item is set to Approved. The remaining workflow actions are then contained within an Impersonation Step, because, in most cases, elevated permissions are required to create a new site. An Impersonation Step runs as the identity of the user that associated the workflow with a list or library. This allows the workflow to perform actions that the user would not normally be allowed to perform, such as creating a subsite for the project.

The workflow then sets the values of the local variables:

  • ProjectName. This variable is set to the value of the Projects Lookup field in the current work item.
  • ProjectSiteUrl. This variable is set to a concatenation of the current site collection URL and the ProjectName variable.

These variables are used as inputs to the actions that follow. Notice how the custom workflow actions are included in the workflow designer:

  • The sentence "The site _ exists" is provided by the Site Exists condition defined in the ExecutionModels.actions file.
  • The sentence "Create subsite at _ using the site template _ using the title _ ..." is provided by the Create a Sub-Site action defined in the ExecutionModels.actions file.
  • The sentence "Copy all items from library _ to site _" is provided by the Copy Library action defined the CopyLibraryModule feature manifest.

No additional configuration is required to use these custom actions in SharePoint Designer. The actions automatically become available when you deploy the ExecutionModels.actions file (for full-trust activities) and the CopyLibraryModule feature manifest (for the sandboxed workflow action) to the SharePoint environment.


Show: