After battling to get it to work, whats the best way to get a workflow to update a multiline text box that contains xml for a nested repeating section?


Badge +2

I need to append xml into a multi line field that already will contain xml for a nested repeating section of a Nintex form.

So far had to regex out the xml declaration and regex the xml tags to be encoded, which is a lot of steps.

Must be an easier way so what have I missed?


3 replies

Userlevel 5
Badge +14

have a look on Update XML action

https://help.nintex.com/en-US/nintex2013/help/#Workflow/RootCategory/Actions/Nintex.Workflow.UpdateXml.htm%3FTocPath%3DW… 

Badge +2

I am using that action to update the parent, but nested XML requires the nested XML nodes to be encoded before saving:

<?xml version="1.0" encoding="utf-8"?><RepeaterData><Items><Item><Nested type="system.string">&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;*ampt;lt;RepeaterData&amp;gt;&amp;l;Items&amp;gt;&amp;lt;Item&amp;gt;&amp;lt;Child &type=amp;quot;system.sting&amp;quot;&amp;gt;child value&amp;lt;child&amp;gt;&amp;lt;Item&amp;gt;&amp;lt;Items&amp;gt;&amp;ltRepeaterData&amp;gt;</Nested></Item></Items></RepeaterData>

if I don't use regex actions to replace <?xml version=""1.0"" encoding=""utf-8""?> with "", i get 'cannot update xml because of multiple xml declarations'

and have to have multiple regex actions

for instance I have to replace <RepeaterData><Items><Item><Child type=""system.string""> with encode values

&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;*ampt;lt;RepeaterData&amp;gt;&amp;l;Items&amp;gt;&amp;lt;Item&amp;gt;&amp;lt;Child &type=amp;quot;system.sting&amp;quot;&amp;gt;
So anyone found a way to pass encoded xml to the update xml action without having to have multiple regex actions to encode it?

I have tried the encodeXML functions, but to no avail

Userlevel 5
Badge +14

you have to proceed step by step

  • get the outer repeater XML
  • get the inner repeater(s) XML(s). I guess you have multiple rows within outer repeating section so you will get multiple inner repeaters. hence store them into a collection
  • loop over the collection
    • within the loop, XmlDecode() single inner repeater XML
    • update single inner repeater XML
    • XmlEncode() updated single inner repeater XML
    • update outer repeater XML on a current row (identified by loop index) with updated and encoded inner repeater XML 
  • update outer XML back to list field

hope that makes sense.

Reply