I'm using below script, and it is working for me,
var oFields = xfa.layout.pageContent(xfa.layout.page(this), "field", 0);
var nNodesLength = oFields.length;
var nSum = 0;
for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) {
if(oFields.item(nNodeCount).name == "NSOLA") {
nSum += parseFloat(oFields.item(nNodeCount).rawValue);
}
}
this.rawValue = nSum;
Be sure that you set field as calculated - read only.
Hope this helps.