>Using Contact Selector in a Modification InfoPath Form


As always things are never as simple as you thought they would be. This post is a case in point, so I have been building a workflow which allows a user to approve a list item. This workflow is built with VS2005 and with previous workflows, the modification forms have worked beautifully.

Well that is until I wanted to include the contact selector inside the modification form. As I mentioned the workflow allows a user to approve the list item, however what if the user is away or want someone else to approve it. Well then a simple workflow modification should sort that, shouldn’t it?!

In order to create a workflow modification you need to do the following:-

  1. Create a form to use for your modification
  2. Update the workflow xml with a modification tag which has a unique GUID and contains the URN of the form that the workflow is going to use.
  3. Implement a EnableWorkflowModification which references the GUID that it is modifying, this is the part where the problem existed (more on that later).
  4. Implement a Event Listener activity so that when the modification occurs there is something listening for it!
  5. Finally implement the handler which updates the workflow and related objects so that the modifications are made.
We will not cover points 1 and 2 as they are discussed in this great post ([insert url]).

So starting with point 3 firstly, so what does an EnableWorkflowModification activity do?

Well it should log that the modification has been activated, it also then assigns the default data that should past into the modification form. Now this is the interesting part, how do you make the xml form data that the InfoPath form requires?

Using a tool called xsd which is part of the VS2005 toolkit. Basically with every InfoPath form there is a XML schema created (.xsd file) if we call xsd /c with the path of the XSD then a code class will be created which is used for serialization/deserialization.

This is used within the EnableWorkflowModification activity to generate the xml ContextData which is then loaded into the Modification form.

In our example we use the serialization class to create a class of the form and then assign values to the various properties of the class. We can then serialize this class to make the xml.

This would be achieved like so:-

ReassingForm reassignForm=new ReassingForm();

reassignForm.ReassingComments = "The workflow is being reassinged from " + m_sApproverLogin;
reassingForm.Approver = ApproverArray;

Here we are assigning the current approver and also uploading some comments to the form, which the user can then update as required.

Finally the class needs to be serialized :-

Now when the workflow modification kicks in then a user gets a link in the workflow status page allowing them to perform the modification. When this is clicked then the Context Data is loaded into the InfoPath form and the InfoPath form is displayed.

When the contact selector is used an error will occur complaining about the fact that the my namespace prefix is not found. So how do we get around this?

We need to tell the serialization method that it should add my prefixes so the xml instead of being like this :-

is like this:-
To do this we need to use the XmlSerializerNamespaces class.
This would look like:-

XmlSerializerNamespaces nsReassignForm = new
nsReassignForm.Add(“my”, “http://schemas.microsoft.com/office/infopath/2003/myXSD/2008-05-29T12:53:57“);

and can be used when calling XmlSerializer.Serialize as additional parameter.
This will then fix the error on form and allow the contact selector to be able to process and store the users that you have provided.

Let me know how you get on.


  1. >Have tried but this namespace serialization solution doesnt work..can u provide some other help about this Unknown error on using contact selector with workflow modification forms


Thoughts? Comments about this post? Please leave them here..

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

WordPress.com Logo

You are commenting using your WordPress.com 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

This site uses Akismet to reduce spam. Learn how your comment data is processed.