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:
In addition to the code on his blog you will need the following code showing how ‘_settings’ and ‘_incidentInfoDoc’ are loaded:
_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();