Is it possible to change the content of a field in a InfoPath form from a workflow in SharePoint. I have tried working with the "Update List Item" action but have been unable to to find a direct way of doing this.


You can always download the xml of the InfoPath form using SPFile and have the workflow modify the contents of the xml file, thus modifying the item. To download the item try something like this

            using (var site = new SPSite(SPContext.Current.Site.Url))
                using (SPWeb web = site.OpenWeb())
                    #region download an intake form and parse into xml

                    //this code lets you download an intake form, parse its xml and save it 
                    SPFile file = web.GetFile(urlOfFile);
                    var sr = new StreamReader(file.OpenBinaryStream());
                    XDocument xdoc = XDocument.Parse(sr.ReadToEnd());
                    return xdoc;

                    #endregion download ...

Then once it's download, grab the XElement of the field you want to modify, and change the value. Then convert the XDocument back to a Stream and save it back to the SPFile using SPFile.SaveBinary() method then use SPFile.Update() to save your changes to the SPFile object.


Easiest way to do this is just promote the column from your InfoPath form so that SharePoint can see it (make sure you allow editing) then you can modify just like any other SharePoint list item (and no need to use any managed code).

I like Meyer's answer though if you are worried about users entering bad values from a datasheet or something and can deploy custom code in your environment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.