Creating Declarative, No-Code Workflow Editors

Applies to: SharePoint Foundation 2010

The websvcWebPartPages web service in Microsoft SharePoint Foundation contains methods that enable a declarative rules-based, code-free workflow editor, such as Microsoft SharePoint Designer 2010, to create workflow templates and associate them with specific SharePoint lists.

These methods include:

  • FetchLegalWorkflowActions() method

    Use this method to get a language-specific list of the valid workflow actions installed for SharePoint Foundation. This enables an application created to act as a declarative workflow editor to display the actions in its user interface.

    The list returned is a merged list that contains the contents of all the .actions files installed on the server, with the core workflow actions included with SharePoint Foundation by default listed first.

    For more information about workflow actions, see SharePoint Designer Workflow Overview.

  • ValidateWorkflowMarkupAndCreateSupportObjects(String, String, String, String) method

    Use this method to validate the workflow markup of a declarative workflow, and optionally, create the support objects necessary for that workflow to run. This includes:

    • Creating the workflow task list, if a task list is not specified in the workflow configuration data, or the specified task list does not exist.

    • Setting each workflow task content types to the specified edit form.

    The method takes the following parameters:

    • XML that represents a workflow markup file in XOML format.

    • XML that represents a workflow rules markup in RULES format.

      For more information about the XOML and RULES workflow formats, see Windows Workflow Foundation.

    • XML that represents a complete workflow configuration file that adheres to the workflow configuration schema.

      For more information about the workflow configuration schema, see Workflow Configuration Schema Overview.

    • A flag value that specifies whether to just validate the workflow markup, or to validate the workflow markup and create the support objects also.

  • AssociateWorkflowMarkup(String, String) method

    Use this method to create a workflow template, and associate that workflow template with the specified SharePoint list.

    This method takes the following parameters:

    • The path to the workflow configuration file to be used for this workflow.

    • The version of the workflow configuration file to use.

    The workflow configuration file contains the information necessary to create a workflow template in SharePoint Foundation from the specified workflow markup and rules files, and to associate it to a specific SharePoint list. Information included in the workflow configuration file includes:

    • The workflow markup and rules files to use, including the appropriate version of those files to use.

    • The SharePoint list to which the workflow should be associated.

    • The task list and history list for the workflow to use.

    • Conditions under which the workflow starts.

    • Workflow initiation form location, data fields, and default values.

    The workflow configuration file must adhere to the workflow configuration schema. For more information, see Workflow Configuration Schema Overview.

When the declarative workflow template is created and associated with the specified list, SPWorkflowTemplate and SPWorkflowAssociation objects are created to represent the workflow template and association, respectively. For declarative workflows, the IsDeclarative property of each object is set to True.

SharePoint Foundation includes a just-in-time compiler to compile the workflow assembly the first time that workflow is started on an item. SharePoint Foundation retains the compiled workflow in memory until it is called again, much like servers cache compiled ASPX pages to speed execution performance the next time the page is called.

Each time a workflow is started on an item, SharePoint Foundation determines whether the workflow was deployed as an assembly or as declarative markup. If a workflow assembly exists, SharePoint Foundation calls that assembly to create the workflow instance. If the workflow was deployed as declarative markup, SharePoint Foundation next determines whether or not it already has a workflow assembly compiled from that markup in memory. If it has, then SharePoint Foundation calls the in-memory complied workflow to create the workflow instance. If not, SharePoint Foundation uses its just-in-time compiler to compile the workflow markup into an in-memory workflow, which it then calls to create the workflow instance.

For a given site, declarative workflows must be stored in a site-level document library called Workflows. The files for each declarative workflow must be stored in a separate folder in the Workflow document library. This includes the workflow markup (.xoml) file, the rules file, and the workflow configuration file. We strongly recommend you also store any workflow forms in the workflow folder.

See Also

Concepts

Workflow Development for SharePoint Foundation

Workflow Configuration Schema Overview

SharePoint Designer Workflow Overview