Skip to main content

Greetings all,



I know I can read or write to process data fields via code such as:


K2.ProcessInstance.DataFields["datafieldname"].Value = value;


Is there similar code that can allow me to read or write from the process XML data, including nested XML fields, easily?


Thanks.

The syntax is slightly different:


K2.ProcessInstance.XmlFields["xmlfieldname"].Value = value;


However, to parse out the other nodes you would need to first load the field into something like an XmlDocument, use XPath to manipulate it, then put it back in the K2 XmlField.  There should be a number of code examples here on underground.


Thanks.


I was hoping since the K2 development GUI is able to use nested field values for things like line rules and such that they had perhaps already implemented some functions that were usable to quickly modify child fields only, rather than having to take the entire XML string and manipulate it myself.


I actually found a less time-consuming workaround; I'm already pulling in some of the nested child values into a SmartObject via a SmartObject event anyway, so I just added another SmartObject event that reads that SmartObject and writes the values into Process Data fields, which are more easily accessible to me when writing code events.


I think that is an interesting approach!


Release 090X of blackpearl will have a new data manipulation event which can manipulate XML fields without code. 


 


That would be quite useful.



Any knowledge of when 09XX might be slated for delivery?  If my understanding of the naming conventions is right, if it's not in the next 75 days or so, it's going to have to be called 10XX...


Just for reference:


Code:


            string xml = K2.ProcessInstance.XmlFieldse"InfoPathXMLSetValue"].Value.ToString();
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.LoadXml(xml);
            System.Xml.XmlNamespaceManager nsMgr = new System.Xml.XmlNamespaceManager(doc.NameTable);
            nsMgr.AddNamespace("my", doc.DocumentElement.GetNamespaceOfPrefix("my"));
            doc.SelectSingleNode("/my:myFields/my:ID", nsMgr).InnerText = K2.ProcessInstance.DataFields:"myDatafield"].Value.ToString();
            K2.ProcessInstance.XmlFields""InfoPathXMLSetValue"].Value = doc.OuterXml;


1.       1.   Change the “InfoPathXMLSetValue” to the name of your form
2.  Change “/my:myFields/my:ID” to the XPath of your field
3.  Change “myDatafield” to the name of your process level data fiel      


 


JAlAlso, the 09xx vs. 10xx isn't year based, it is build based


 


 


 


A


Will that be included in the BlackPoint version as well.


 


Thanks


-George Gergues


Blackpoint already has the Data Manipulation event wizard


Reply