Updating InfoPath promoted column in MOSS from Workflow/Application Page

Updating InfoPath promoted column in MOSS from Workflow/Application Page

This is something I have been having problems with for ages and thanks to Chris Jones I have now found the solution.

If you try to update the value of an InfoPath promoted column within MOSS (from a workflow/application page or other) you will notice that the item[“fieldname”] = “Something” method does not work.

This method works fine for normal SharePoint columns but when it comes to InfoPath promoted fields/columns, it simply will not update the column at all.

Chris has posted some code on his blog which I can confirm updates the column within MOSS and on the form itself, it basically opens the xml document, navigates to the particular data to update and then saves the document back to SharePoint.

Chris modified this code from a forum post but could not find the original author so thanks to them too!

You will need to pass in the XPath of the field you wish to update and the URN of your form.

See Chris’s code here:

http://www.qualitysharepoint.com/2009/03/update-infopath-form-from-workflow.html

In addition to the code on his blog you will need the following code showing how ‘_settings’ and ‘_incidentInfoDoc’ are loaded:

**CODE**
[code lang="csharp"]
_settings.NamespacePrefix = “my”;

_settings.Namespace = “http://schemas.microsoft.com/office/infopath/2003/myXSD/2008-09-22T20:08:03”;

//And _incidentInfoDoc is loaded like this

SPFile file = _workflowProperties.Item.File;

using (var streamReader = new StreamReader(file.OpenBinaryStream()))
{
string content = streamReader.ReadToEnd();

_incidentInfoDoc = new XmlDocument();

_incidentInfoDoc.LoadXml(content);
}
[/code]

**CODE**

Cheers Chris!

6 thoughts on “Updating InfoPath promoted column in MOSS from Workflow/Application Page

  1. Pingback: Infopath – Promoted Fields In Sharepoint « Sladescross's Blog

  2. Pingback: Infopath – Promoted Fields In Sharepoint « Sladescross's Blog

  3. Sonny

    Hi,

    I clicked on the link to Chris’ code and wasn’t able to find the code on the site it brought me to. Any idea if the code is still accessible elsewhere?

    I’m new to SharePoint development and have come across the same situation where I’m trying to retrieve promoted columns and can’t.

    Thanks for any help.

    1. Alex Post author

      Hi Sonny,

      Sorry but I don’t have the code anymore – I was going to post it on my blog but didn’t want to steal what he’d done. I guess he has maybe sold his domain now as its no longer accessible – i’m not even able to locate it looking at the google cache.

      Sorry I cant be more helpful.

      Cheers

      Alex

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">