MikeGillespie

Gel Looping and Updating XML

Discussion created by MikeGillespie on Aug 16, 2011
Latest reply on Sep 8, 2011 by ddeneer
I need to make a duplicate record of an existing object. The object is a sub-object of the project object and it contains sub-objects. Both sub-objects contain auto numbering schemes on their name and id.

It looks like this:
Project

Sub-Object


Sub-Object 1

I need to use gel and a process so the users can run this when needed.

I can successfully create the xml file in memory of a gel script which is the write of the object to duplicate. I can also successfully xog back in the xml to insert the new record. What I can’t seem to get working is modifying the xog write xml to make it unique.

The original xog read is attached.

As you can see it is one sub-object of the project object and it contains two sub-object records. In order to duplicate this record the following changes need to be made to it:
1.
Add overrideAutoNumbering="0" to the Header section to support auto numbering
2.
Change the instanceCode value in the first sub-object to -1. This enables auto numbering on the field.
3.
In each of the sub-object 1 sections change the value of name, code and parentInstanceCode to -1.

The new xog file is attached.

What I am struggling with is how to loop through the xml within gel and make the needed changes to both the sub-object and sub-object 1. I have looked through the board and saw a reference to using gel:forEach to do the looping but I have been unable to get this to work. Also I am not sure how to specifically change a xml node value. I can change and entire path in the xml but I only what to change the specific value of a node.

Does anyone have an example of looping through an xml file using gel that updates specific node values they could share? Also something that adds to a section to support putting in the overrideAutoNumbering="0" to the header section.

Thank you.

Outcomes