This document discusses using InfoPath task forms with SharePoint workflows. It demonstrates how to pass data between an InfoPath form and a workflow task by serializing the form data to XML and passing elements as extended workflow properties. Limitations of this approach include case sensitivity and inability to pass complex data types. An alternative approach is presented using a common XSD and serialization/deserialization to safely pass the entire form data to the task.
4. Info Path Uses xsd files to define data types. Easy to create Form UI by drag and drop. Use a secondary data source to transfer data between Workflow Task extended properties and Info Path Task Forms. Case sensitive and impossible to debug the transfer. No Type Safety during transfer, everything is a string.
6. SharePoint Workflow Have full access to the InfoPath Form xml for the item that this workflow instance is attached. Have indirect access to the InfoPath Task Forms using Extended Properties Hard or impossible to pass arrays and complex data types.
7. 1) Deserialize the current InfoPath Form XmlSerializerserializer = new XmlSerializer(typeof(expenseReport)); using (Stream stream = this.workflowProperties.Item.File.OpenBinaryStream()) { Expenses = serializer.Deserialize(stream) as expenseReport; } 2) Pass the data to the task forms ApproveTaskProperties.ExtendedProperties["EmployeeName"] = Expenses.employee.name; ApproveTaskProperties.ExtendedProperties["ExpenseTotal"] = Expenses.items.total.Value.ToString();
8. Demo Keep data safety and access all Info Path Form data inside Workflow. XmlSerializerserializer = new XmlSerializer(typeof(expenseReport)); using (Stream stream = this.workflowProperties.Item.File.OpenBinaryStream()) { Expenses = serializer.Deserialize(stream) as expenseReport; } Show how to transfer data to a task and talk about limitations. ApproveTaskProperties.ExtendedProperties["EmployeeName"] = Expenses.employee.name; ApproveTaskProperties.ExtendedProperties["ExpenseTotal"] = Expenses.items.total.Value.ToString();
10. Demo Pass the whole form data to the task and display complex types.
11. Conclusion Design the Forms with data in mind Create a common xsd to be used across the Item Form and Task Forms. Use another xsd as the principal for Item and Task Form. Generate the forms from the xsds Generate classes from the xsds Use single namespace for all forms generated classes Use serialization/de-serialization to pass data.
12. Resources: InfoPath Team Blog: http://blogs.msdn.com/infopath/ Microsoft SharePoint Team Blog: http://blogs.msdn.com/sharepoint
13. Thank you Florin Muntean Florin.Muntean@philips.com http://fmuntean.wordpress.com
Editor's Notes
Add Philips logo
Show the xsd schema for one fieldShow the command to generate a class from it: xsd.exe ExpenseReportForm.xsd /c /namespace:MFD.Expenses.FormData
Approval 1
InfoPath forms are xml files.We can serialize a class as an xml and pass it to the extended properties.Why not use the same class that we generated from the task form?We use a special tag that we read and forcedly send it as the main data source to the task form.
Approval 2
<xsd:import namespace="http://schemas.microsoft.com/office/infopath/2003/expXSD" schemaLocation="ExpenseReport.xsd"/>Use single namespace for all