Workflow Association and Initialization Forms in SharePoint Server 2010 (ECM)

Applies to: SharePoint Server 2010

In this article
Specifying Association Forms
Association Form Processing
Specifying Initiation Forms
Initiation Form Processing

Before the workflow starts, you can display association and initialization forms to your users so that they can set parameters and other information for the workflow in advance. Association forms address the workflow as it applies to a specific list, library, or content type; initialization forms address the workflow as it applies to a specific SharePoint item.

You can also include pre-association data in the workflow template definition. For example, you might want to prepopulate fields on your association form with default values.

For more conceptual information about association and initialization forms, see Workflow Association and Initiation Forms (Sharepoint Foundation) in the Microsoft SharePoint Foundation SDK.

Specifying Association Forms

As with all workflow forms, you specify the association form of a workflow in the workflow template definition XML. To do this, you edit two XML elements.

  1. Set the value of the AssociationURL attribute of the Workflow element to "_layouts/CstWrkflIP.aspx". This is an .aspx page included with Microsoft SharePoint Server 2010; the page includes an InfoPath Forms Services Web Part to host the Microsoft InfoPath 2010 workflow association form:

    AssociationURL ="_layouts/CstWrkflIP.aspx"
    

    Note

    SharePoint Server 2010 supports absolute or server-relative paths in the workflow template definition. You must express all form path URLs in one of these formats. For example, an absolute path, such as "http://site/library/page.aspx"; or a server-relative path, such as "/layouts/page.aspx". Office SharePoint Server 2007 does not support link fix-up in workflow template definitions.

  2. Add an Association_FormURN element to the Metadata element in the workflow template definition. Use this element to specify the URN of the Office InfoPath 2007 form you want to use for workflow association. For example:

    <Association_FormURN>urn:schemas-microsoft-
        com:office:infopath:workflow:ReviewRouting-Assoc
    </Association_FormURN>
    

    If you want to provide custom data to the association form, you can store this information in the AssocationData element. For example, you can use this element to store default values you want to pass to the association form when it is displayed. The AssocationData element can contain any valid XML.

For more information about the workflow definition schema, see Workflow Definitions in the Microsoft SharePoint Foundation SDK.

Association Form Processing

When an administrator selects a workflow to associate with a given list, library, or content type, SharePoint Server 2010 displays the Add a New Workflow page; here the administrator can specify settings common to all workflows, such as the workflow definition, initiation conditions, and whether the workflow runs on items, folders, or both.

When the administrator clicks the Next button on this page, SharePoint Server 2010 examines the AssociationURL attribute of the Workflow element in the workflow template definition, to determine the proper .aspx page to load. For an InfoPath 2010 form, the developer sets this value to _layouts/CstWrkflIP.aspx. SharePoint Server 2010 loads this page, which contains an Office InfoPath Forms Services Web Part for hosting the custom form. The page then examines the Association_FormURN element of the workflow template definition XML to determine the proper InfoPath 2010 form to host. In addition, this Web Part passes any data stored in the AssocationData element to the InfoPath 2010 form.

When the administrator submits changes to the form, CstWrkflIP.aspx passes the data back to SharePoint Server 2010 as an XML string. The data is stored in the AssociationData property of the SPWorkflowAssociation object that represents that workflow association.

Specifying Initiation Forms

To specify an InfoPath 2010 workflow initiation form, you must edit two elements in the workflow template definition.

  1. Set the value of the InstantiationURL attribute of the Workflow element to "_layouts/IniWrkflIP.aspx". This is an .aspx page included with SharePoint Server 2010; the page includes an Office InfoPath Forms Services Web Part to host the InfoPath 2010 workflow initiation form:

    InstantiationURL="_layouts/IniWrkflIP.aspx"
    

    Note

    SharePoint Server 2010 supports absolute or server-relative paths in the workflow template definition. All form path URLs must be expressed in one of these formats. For example, an absolute path, such as "http://site/library/page.aspx", or a server-relative path, such as "/layouts/page.aspx". SharePoint Server 2010 does not support link fix-up in workflow template definitions.

  2. Add an Instantiation_FormURN element to the Metadata element in the workflow template definition. Use this element to specify the URN of the InfoPath 2010 form you want to use for workflow initiation. For example:

    <Instantiation_FormURN>urn:schemas-microsoft-
        com:office:infopath:workflow:ReviewRouting-Init:1033
    </Instantiation_FormURN> 
    

Initiation Form Processing

When a user starts a workflow on a given item, SharePoint Server 2010 examines the InstantiationURL attribute of the Workflow element of the workflow template definition XML to determine the proper .aspx page to load. In the case of an InfoPath 2010 form, the developer sets this value to "_layouts/IniWrkflIP.aspx". SharePoint Server 2010 loads this page, which contains an Office InfoPath Forms Services Web Part to host the custom form. This page then examines the Instantiation_FormURN element of the workflow template definition XML to determine the proper InfoPath 2010 form to host. In addition, the page passes, as an XML string, the association data stored in the AssociationData property of the appropriate SPWorkflowAssociation to the InfoPath 2010 form. This data serves as the primary data source of the form.

When the user submits changes to the form, IniWrkflIP.aspx passes the data back to the SharePoint Foundation object model, as part of calling the StartWorkflow method.

The workflow manager in SharePoint Server 2010 creates an instance of the workflow on the SharePoint item. The workflow manager passes the data gathered using the initiation form to the OnWorkflowActivated event of the workflow itself.

See Also

Tasks

How to: Design InfoPath Workflow Forms (ECM)

How to: Access Association and Initiation Form Data in a Workflow in SharePoint Server 2010 (ECM)

How to: Design a Workflow Form to Use Association and Initiation Data in SharePoint Server 2010 (ECM)

Concepts

Workflows in SharePoint Server 2010 (ECM)

InfoPath Forms for Workflows (ECM)

Workflow Modification Forms in SharePoint Server 2010 (ECM)

Workflow Task Forms in SharePoint Server 2010 (ECM)

Other Resources

Workflow Definition Schema for InfoPath Forms