Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Calculating Field sum over multiple pages

Avatar

Level 1

Hey all,

i seriously need the help of the adobe community - your help! Id like to calculate the fieldsum of multiple fields in a grand total field. My problem is that the subfields are on more than one page, therefore i was trying to use a for loop to get all my subtotals in the whole document and sum them in the grandtotal. But that not working for me, any suggestions would be great. Right now im using this piece of code :

for (var nPageCount = 0; nPageCount < xfa.host.numPages; nPageCount++)

{

var fields = xfa.layout.pageContent(nPageCount , "field", 0);

var total = 0;

for (var i = 0; i <= fields.length-1; i++) {

     if (fields.item(i).name == "Positionspreis") {

         total = total + fields.item(i).rawValue;

     }

}

this.rawValue = total;   

}

Any help would be great!

BR

1 Reply

Avatar

Level 10

Hi,

I think the line "this.rawValue = total;" should be after the top for loop, otherwise your total will only include the fields on the last page.

Regards

Bruce