This example demonstrates how to calculate the sums of fields located at different levels of the form hierarchy when the form filler opens the form in a client application, such as Acrobat Professional, Adobe Reader, or HTML client.
Livecycle eg calc sum Calculating the field sums
var fields = xfa.resolveNodes(“NumericField1[*]“);
var total = 0;
for (var i=0; i <= fields.length-1; i++) {
total = total + fields.item(i).rawValue;
}
this.rawValue = total;
var fields = xfa.resolveNodes(“detail[*].NumericField1″);
var total = 0;
for (var i=0; i <= fields.length-1; i++) {
total = total + fields.item(i).rawValue;
}
this.rawValue = total;
var fields = xfa.layout.pageContent(0 , “field”, 0);
var total = 0;
for (var i=0; i <= fields.length-1; i++) {
if (fields.item(i).name ==”NumericField1″) {
total = total + fields.item(i).rawValue;
}
}
this.rawValue = total;
See also 

Calculating the field sums