Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

script code sample for looping through the records from xml data file in formCalc script


Not applicable
I have a xml data file which contains a sequence of repeating applicant data like given below












113 Lazlo LaneCA
Suite 3500CA

I want to assign a textfield with a value based on the value of coap_flag.
So i need to loop through all the record and check the value of coap_flag and then assign the textfield a value based on that.

I am new to Adobe livecycle...Please help me how it can be done.

I have developed something like this
foreach Item in ($record.applicant[*].coap_flag) do
7 Replies


Level 10
No need to go through script to do this. In the dataview create a new connection and import a sample data file or the corresponding schema. A heirarchy of your xml file will appear. Locate the coap_flag field and drag and drop it onto the field that you want to set. A binding between the field and the data node is now established (you can see this by looking at the binding tab and on the heirarchy an icoon showing that this node is boound appears). Thats it....import you data file and the value will end up in that field.


Not applicable
I think u r not clear with my problem. I have given above the applicant data hiaerarchy which is in my data file. I have lot of applicant data available in the xml file with with this hiaerarchy. I want to display only some applicant details in a text field based on the value of the coap_flag. So i want to loop and check all the Applicant coap_flag and if the coap_flag matches my value i should be able to display my values in the field.

Now I am not able to get the loop executed. I am only able to get the value of the first Applicant..

Please help me.


Level 10
How are you getting the value?


Not applicable
I am only getting the data value of first applicant in the applicant hierarchy . For example in the above example i am getting the value of first applicant coap_flag value i.e "GU". But i need ti check other applicants coap_flag values also to decide which applicant data i need to enter within the textfield.


Level 10
It has been a while since I played with the multiple occurances in the data dom. If you post a sample data file I can create a form that will show you how to get access to the individual repeating nodes. You can post it to


Not applicable
Hi thanks for the reply<br /><br />Actually I was able to retrieve those multiple data instances of the same named node using the javascript code given below.<br /><br /> var oItems = this.resolveNodes("record.applicant[*].coap_flag"); <br /> var iItems = this.resolveNodes("record.applicant[*]");<br /> var test="";<br /> for(var i=0;i<oItems.length;i++)<br /> {if(oItems.item(i).value=="MA")<br /> {test = String.concat();<br /> }<br /> <br /> } <br /> this.rawValue=test;


Level 10
Using the data you posted in the forum, I copied it a couple of times to give multiple records and used this code to extract the different values that you wanted. I had to wrap it in a <root> node that I called root (to make it valid XML). In my case I wrote the extracted values to a field, but in your case you can do whatever you want with them. Note that this was done in javascript:<br /><br />var currentElement;<br />var obj;<br /><br />//Get the nodes below the root node in the dataDom<br />obj =;<br /><br />//Set an initial value for the textField<br />TextField1.rawValue = "The values of the coap_flag are: ";<br /><br />//Loop through the nodes in the obj set <br />for (i=0; i< obj.length ; i++){<br /> //set the currentElement to the 1st child node<br /> currentElement = obj.item(i);<br /> //Check to see if it is an applicant node<br /> if ( == "applicant"){<br /> //It is an applican, now find the coap_flag node value and write it to the text field<br /> TextField1.rawValue += "\n" + xfa.resolveNode("[" + i + "]").coap_flag.value;<br /> }<br />}