One of the more frustrating experiences I encountered when creating InfoPath Task Forms for my SharePoint workflow was trying to take the richtext value from one form, and pass it into a richtext field on a second form. The problem I was encountering was whenever I tried setting the value in the ExtendedProperties, the form would load up with the XHTML code, and not apply the formatting as seen below:

The solution to this is actually not that complicated and all you need to do is modify your InfoPath form.

  1. Open your InfoPath form up in design mode.
  2. Click the Tools Menu > Form Options
  3. In the Form Options select Security and Trust and change the Trust Level to “Full”.
  4. Next select the “Programming” section and choice the language of your choice, I choose C#.
  5. Press OK.
  6. Select the Tools Menu > Programming > Loading Event
  7. Visual Studio should now open.
  8. Insert the following code, or variation there off in the Loading method:
            public void FormEvents_Loading(object sender, LoadingEventArgs e)
                    XPathNavigator secondaryDataSource = this.DataSources["ItemMetadata"].CreateNavigator();
                    string instructions = secondaryDataSource.GetAttribute("ows_instructions", "");
                    XPathNavigator mainDataSource = this.MainDataSource.CreateNavigator();
                    mainDataSource = mainDataSource.SelectSingleNode("/my:myFields/my:instructions", NamespaceManager);
                    mainDataSource.InnerXml = instructions;
                catch (Exception ex)
  9. UPDATE: Finally the last step here is deploying the dll created with your form to your workflow. When you attach a code behind event, InfoPath generally created a project folder for it in your My Documents\InfoPath Projects\[Form Name] folder. You can change the location of where this file is located in the Form Options menu, under the Programming section. Regardless navigate to where you code was compiled to. Sneak in and grab the compiled .dll.

    You’ll need to copy this .dll into your Workflow feature folder:

    [default = c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\ARPProcessWorkflow\].

That’s all there is too it. Some things to note that might not be so obvious. My secondaryDataSource is the ItemMetadata.xml. If your not familiar with how to pass values from the SharePoint workflow into the task form you should read my other post about passing field values from the workflow into the task form. Another thing to note is that the name of my particular field is instructions, and likewise the attribute in my ItemMetadata.xml is ows_instructions.

My apologies to Fred who discovered that I missed this step. If you don’t perform this step you’ll receive an error when your Form renders along the lines of:

Could not load file or assembly ‘file:///C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\Features\[WorkflowName]\[FormName].dll’ or one of its dependencies. The system cannot find the file specified

Anyways hope this helps.

Posted by Chris Buchanan

Leave a reply

Your email address will not be published. Required fields are marked *