How to: Design a Workflow Form to Use Association and Initiation Data

When Microsoft Office SharePoint Server 2007 displays a custom Microsoft Office InfoPath 2007 form for workflow association or initiation, it also passes the form any association or initiation data as XML. For a form control to display an element of this XML, the form control must be data-bound to that XML element. Office SharePoint Server 2007 automatically performs this data-binding for workflow association and initiation forms, as described in this topic.

Data-Binding Form Controls to Association Data

When Office SharePoint Server 2007 displays a custom InfoPath form for workflow association, it calls the Forms Server control to convert the form into a Microsoft ASP.NET 2.0 page and host it. As part of the form load, the Forms Server control passes any predefined association XML data to the form as XML. The Forms Server control automatically data-binds any elements to the form control of the same name. For example, the Forms Server control would automatically data-bind a form control named Comments to the data element Comments. You do not have to explicitly define the association data schema as a secondary data source.

To use association data, name your form control the same as the element in the association data XML.

You can specify default association data in the AssociationData element of the workflow definition file for your workflow solution. For more information, see Workflow Definition Schema Overview in the Microsoft Windows SharePoint Services 3.0 SDK.

In the same way, the Forms Servers control passes the association form data back to Windows SharePoint Services. The workflow association data is stored as XML in the AssociationData property of the appropriate SPWorkflowAssociation object. When a workflow instance starts, this data is also passed into the workflow via the AssociationData property of the SPWorkflowActivationProperties object.

For more information about how association forms are specified and processed, see Workflow Association and Initialization Forms.

To data-bind form controls to association data

  • Name your InfoPath form control the same as the element in the association data XML.

Data-Binding Form Controls to Initiation Data

When Office SharePoint Server 2007 displays a custom InfoPath form for workflow initiation on the server, it calls the Forms Server control to convert the form into an ASP.NET 2.0 page and host it. As part of the form load, the Forms Server control retrieves the initiation data from the AssociationData property of the appropriate SPWorkflowAssociation object, and passes it to the initiation form as XML. The Forms Server control automatically data-binds any elements to the form control of the same name. For example, the Forms Server control would automatically data-bind a form control named Comments to the data element Comments. You do not have to explicitly define the initiation data schema as a secondary data source.

Note

The Forms Server control is invoked only if you initiate the workflow from the Office SharePoint Server 2007 Web browser interface. If you initiate the workflow from a 2007 Microsoft Office system client application, such as Microsoft Office Word, Microsoft Office PowerPoint, or Microsoft Office Excel, the application can host the InfoPath workflow initiation form without converting the form to ASP.NET 2.0. However, in each case the data-binding operation is handled in the same way.

To use initiation data, name your form control the same as the element in the initiation data XML.

In the same way, the Forms Server control handles starting the workflow itself, and passing the initiation form data to the new workflow instance. After the workflow starts, the initiation data is stored in the InitiationData property of the SPWorkflowActivationProperties object returned by the WorkflowProperties property of the OnWorkflowActivated activity.

For more information about how initiation forms are specified and processed, see Workflow Association and Initialization Forms (Office SharePoint Server 2007).

To data-bind form controls to initiation data

  • Name your InfoPath form control the same as the element in the initiation data XML.

See Also

Other Resources

InfoPath Forms for Workflows
Workflow Association and Initialization Forms
Workflow Definition Schema for InfoPath Forms
How to: Design an InfoPath Form for an Office SharePoint Server 2007 Workflow
How to: Access Association and Initiation Form Data in Your Workflow