In The Mix

As a SharePoint architect I have the business behind me and the Developers and IT Pro on my shoulders.

Info Path Task Forms Made Easy October 28, 2008

Filed under: SharePoint — fmuntean @ 8:43 am

[Update November 2009] A follow up post with source code, demos and instructions for this approach is available here:

If you are using an InfoPath library there is a very easy and safe way to work with the xml InfoPath generated data.

You get and set data on the item is by using xml de/serialization as shown in the next snippet:

SPItem item = ....
YourInfoPathFormClass yourForm;
XmlSerializer serializer = new XmlSerializer(typeof(YourInfoPathFormClass));
using (Stream stream = item.File.OpenBinaryStream())
        yourForm = serializer.Deserialize(stream) as YourInfoPathFormClass;

Now YourInfoPathFormClass is generated using the xsd utility from the InfoPath Form xsd files: xsd.exe YourForm.xsd /c /namespace:YourNameSpace

When it comes to the Workflow and InfoPath Task Forms, this easy and type safe way does not work. Microsoft decided to use a rather complicated and convoluted mechanism to pass data between Workflow and the InfoPath Task Form. So you find yourself building helper classes with lots of lines just to encapsulate the strings used inside the Task Form. For simple Task Forms this is not a big problem but it will be if your Workflow has many complicated Task Forms. Another problem that you will face is the inability to use complicated types inside Task Forms because the Extended Properties contains a flat list of key value pairs.

I would like to be able to use the first approach for Task Forms too. All I needed is for Microsoft to have passed the InfoPath xml data as an Extended Property and I would be able to de/serialize my Task Form data in xml format inside that Extended Property.

So again I put my "Reverse Engineer" Hat on and start looking at how Microsoft built the interface between InfoPath and SharePoint Workflow Task Forms.

Following are my findings:

A content type is used to differentiate between the OOB Task Forms and the InfoPath ones. A ItemMetadata xml file is used to transfer data between the InfoPath Form and SharePoint. The WrkTaskIP.aspx inside _Layouts is the page that contains the InfoPath XMLFormControl that displays the InfoPath Form and controls the data flow between the Task and SharePoint. For more info on InfoPath Tasks Forms read the following MSDN article:

Having all this information now we can modify the way that we send and receive data from the InfoPath Task Forms:

1. Create a new Content Type that derives from the InfoPath Content Type and uses a different WrkTaskIP.aspx page.

2. Copy the WrkTaskIP.aspx page under the same name that you have used in the custom Content Type and modify the copy to implement the page from a custom class.

3. Create a Custom Class that derives from  WrkTaskIPPage and add the following references:, Microsoft.Office.Workflow.Pages (you can found this in the _app_bin folder), Microsoft.SharePoint,System.Web, System.Xml

4. Now in the custom class we will need to override the following events using the OnInit method as shown in the following snippet:

protected override void OnInit(EventArgs e)
      base.XmlFormControl.Initialize -= new EventHandler<InitializeEventArgs>(base.XmlFormControl_Initialize);
      base.XmlFormControl.Initialize += new EventHandler<InitializeEventArgs>(this.XmlFormControl_InitializeNew);
       base.XmlFormControl.Close -= new EventHandler(this.XmlFormControl_OnClose);
       base.XmlFormControl.Close += new EventHandler(this.XmlFormControl_OnCloseNew);

5. You will be sending data to the InfoPath form in the InitializeNew and get data from the InfoPath form in the OnCloseNew methods.

6. Personally I chose to use "IPFormDataXML" as a key in the Extended Properties to pass data back and forth.

7. Make sure that you build everything as a SharePoint solution.

Now to work with the InfoPath Task Form all we need is to again generate the classes from the Task From xsd schema and de/serialize data in the Extended Properties (make sure that you now specify your content type  inside the workflow.xml file for the TaskListContentTypeId attribute.

For more info drop me a line.


11 Responses to “Info Path Task Forms Made Easy”

  1. RaiulBaztepo Says:

    Very Interesting post! Thank you for such interesting resource!
    PS: Sorry for my bad english, I’v just started to learn this language 😉
    See you!
    Your, Raiul Baztepo

  2. If you want to hear a reader’s feedback 🙂 , I rate this post for 4/5. Detailed info, but I just have to go to that damn yahoo to find the missed pieces. Thanks, anyway!

  3. machendra Says:

    Hi Sir,

    I have a problem in updating the task form repeating table with the request form repeating table data.. could you plz explaing how can i do this..

    actually i am not able to get the tsk form xml document..

    plz help me it is very urgent..i have to deliver my project on monday..

  4. fmuntean Says:

    Hi Machendra,

    I am actually in vacation right now but shortly:
    If the repeating table from the task form has the same schema as the repeating table from the request form then all you need to do is the following.
    Create a common XSD file that contain the definition for the repeating table and any other common fields between the request and task forms.
    Then use that XSD and another XSD file for the fields specific to each of your forms. Compile the XSDs and using my approach all you will need to do is to do a assignment and serialization.

    Task.RepeatingTable = Form.RepeatingTable

    NOTE: If you are not using a common XSD for the repeating table then you will need to manually copy all the fields:

    Task.RepeatingTable.Field1 = Form.RepeatingTable.Field1;
    Task.RepeatingTable.FieldN = Form.RepeatingTable.FieldN;

  5. Daniel Says: – InfoPath Form Template management using SharePoint Document libraries and content types.

  6. sanjaya Says:


    using ItemMetadata.xml,i am passing “true” when approve button click.(using Rule and also dataconnection submittingtohost)

    but i am not able to get this value in workflow extended properties

    my code is as below
    isFinished = bool.Parse(on_FT_TaskChanged_AfterProperties.ExtendedProperties[“isFinished”].ToString());

    could you tell me what will be the problem.

  7. fmuntean Says:

    I guess that you missunderstood my approach.
    I am not using ItemMetadata.xml at all.
    I am replacing the page that displays the InfoPath task form and I am passing the xml for the task form dirrectly into a special ExtendedProperties tag.
    When the user closes the task form I receive the new xml back in the same ExtendedProprieties tag. After this I am deserializing that xml into a class that was generated using the xsd schema file from the task itself.
    This way I can overcome the ItemMetadata.xml limitations and I have data type validation all the way through.
    This approach also allow me to initialize and access the task data in an object oriented way using the task generated class properties.

    Let me know if this make sense or you need more info,

  8. […] a previous post I have talked about an approach of transferring complex data between the workflow and the InfoPath […]

  9. broosauff Says:

    True words, some truthful words dude. Totally made my day.

  10. Madhu Says:


    Thanks for such a great post, it was very helpful for me. But I would like to save and retrieve digital signature info. How can we save and load the digital signatures. Any kind of help will be gratly appreciated.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s