Order of Operations



Hi All,

Attempting to sum two rows multiplied to each other (before they are summed as some of the values are zero) as well as infuse this calculation into a current fields calculation (at bottom) and have been unsuccessful thus far. Was not able to find something similar in past posts so thought I would take a shot at finally joining the forum and just asking the question.  Can anyone help?  Unable to get this to work in formcalc either.  Not looking for just the answer, looking for the logic behind it as well so that I can understand how it works.  Thanks in advance!

Looking for field "NON" and field "WAD" multiplied, then summed (for all rows), then subtracted from NumericField17 "days +1" value.

//Unsuccessful Test Script to Multiple Two Column's Values in a Dynamic Table

var page = xfa.layout.page(this)-1; 

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

this.rawValue = 0; 

var total = 0; 

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

    if (fields.item(i).name == "NON"&&WAD(i).rawValue == "1")     { 

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


this.rawValue = total;

//Successful Script to Calculate Days

   var regularDate1 = new Date(PBE.Page1.ProjectInfoSubform.Table3.Row3A.PEnd_Date.rawValue.replace(/-/g, "/"));

   var regularDate2 = new Date(PBE.Page1.ProjectInfoSubform.Table3.Row3A.PStart_Date.rawValue.replace(/-/g, "/"));

   var milliseconds = regularDate1.getTime() - regularDate2.getTime();

   var nMilliSecondsPerDay = 24 * 60 * 60 * 1000;

   var days = Math.floor(milliseconds / nMilliSecondsPerDay);

   NumericField17.rawValue = (days + 1)

Accepted Solutions (0)

Answers (0)