Perfect spot to use JavaScript’s array.reduce method:
var flds = ['count1,'count2','count3','count4']; // add all field names here
flds.reduce( function(accumulator, currentValue) {
return accumulator + (data.extract(currentValue,0)*1);
},0);
Thank you, I didn’t use your script, but I solved it with the workflowplugin.
I also had some difficulties to fill the variable as the were in the detail table. the datamapper kept giving me an error.
var flds = [[record.tables["detail"][index].fields["count1"],record.tables["detail"][index].fields["count2"]]; // add all field names here
flds.reduce( function(accumulator, currentValue) {
return accumulator + (data.extract(currentValue,0)*1);
},0);