Skip to main content
Nintex Community Menu Bar

How do I populate a process datafield from an infopath XML field?

  • July 21, 2008
  • 4 replies
  • 26 views

Forum|alt.badge.img+6

As of this writing the Simple Data Mapper wizard event is not yet available for BlackPearl.  For now, within a default server code event it is relatively easy to pull data from your XML fields into your process datafields.  Use the following code, customizing your SchemaName for the text SchemaName below.  You would need an XML field called Notes and a Process Datafield called Notes for this to work.

          //substitute your SchemaName here (K2ObjectBrowser>DataTab>XMLFields>the one below "activities" is your SchemaName)
          string XMLString = K2.ProcessInstance.XmlFields["SchemaName"].Value;


          //the double slash "//" in the XPATH makes the xmlhelper search for the field name, if you had more than one Notes fields you would need a more concise XPATH
          K2.ProcessInstance.DataFields["Notes"].Value = SourceCode.Workflow.Common.XmlHelper.GetXPathValue(XMLString, "//my:Notes");


Hope this helps,


Joseph

4 replies

Forum|alt.badge.img+6
  • Author
  • July 23, 2008
It is worth noting that when an activity contains an Infopath Client Event, the XML is reintegrated into the process at the end of the activity.  This means that if you insert server code events like the example above, after the Infopath Client Event and before the end of the activity, the changes you make to the XML will be lost.  The best way to accomplish this is to place any server code event in the activities following your Infopath Client Event Activity.

Forum|alt.badge.img+6
  • Author
  • July 23, 2008
It is worth noting that when an activity contains an Infopath Client Event, the XML is reintegrated into the process at the end of the activity.  This means that if you insert server code events like the example above, after the Infopath Client Event and before the end of the activity, the changes you make to the XML will be lost.  The best way to accomplish this is to place any server code event in the activities following your Infopath Client Event Activity.

Forum|alt.badge.img

I understand your example but I am unsure of how I would find out the "SchemaName". Could you provide a little help in this area of your example?


Thank you,


 


Matt


 


Forum|alt.badge.img+11
  • September 3, 2008
In Joseph's example, "SchemaName" is the name of the XML data field.  It is the name you give the data field when you create it.