Copy link to clipboard
Copied
I have created the following code and the result is NaN. I would expect it to be the sum of all values in total1 multiplied by 1 or 1.5 based on the results of IF statements above it. What am I missing?
//Get all the values needed
var Pole1p = +getField("SP_Pole_Quantity").value;
var Secondary1p = +getField("SP_SecondaryUG_Quantity").value;
var Primary1p = +getField("SP_PrimaryUG_Quantity").value;
var Pole3p = +getField("3P_Pole_Quantity").value;
var Secondary3p = +getField("3P_SecondaryUG_Quantity").value;
var Primary3p = +getField("3P_PrimaryUG_Quantity").value;
var term = +getField("ContractLength").value;
var PoleCost1p = +getField("SP_Pole_Ext_Cost").value;
var MeterCost1p = +getField("SP_MeterLoop_Ext_Cost").value;
var ServiceCost1p = +getField("SP_ServiceDrop_Ext_Cost").value;
var XfmerCost1p = +getField("SP_OH_Xfmer_Ext_Cost").value;
var SecondaryCost1p = +getField("SP_Secondary_UG_Ext_Cost").value;
var PrimaryCost1p = +getField("SP_PrimaryUG_Ext_Cost").value;
var PadCost1p = +getField("SP_PadXfmer_Ext_Cost").value;
var PoleCost3p = +getField("3P_Pole_Ext_Cost").value;
var MeterCost3p = +getField("3P_MeterLoop_Ext_Cost").value;
var ServiceCost3p = +getField("3P_ServiceDrop_Ext_Cost").value;
var XfmerCost3p = +getField("3P_OH_Xfmer_Ext_Cost").value;
var SecondaryCost3p = +getField("3P_SecondaryUG_Ext_Cost").value;
var PrimaryCost3p = +getField("3P_PrimaryUG_Ext_Cost").value;
var PadCost3p = +getField("3P_PadXfmer_Ext_Cost").value;
var Windrow10Cost = +getField("10_Windrow_Ext_Cost").value;
var Windrow15Cost = +getField("15_Windrow_Ext_Cost").value;
var Windrow30Cost = +getField("30_Windrow_Ext_Cost").value;
var Chip10Cost = +getField("10_ChipRemove_Ext_Cost").value;
var Chip15Cost = +getField("15_ChipRemove_Ext_Cost").value;
var Chip30Cost = +getField("30_ChipRemove_Ext_Cost").value;
var Removal30Cost = +getField("30_Removal_Ext_Cost").value;
var Easement1Cost = +getField("Easement1_Cost").value;
var Easement2Cost = +getField("Easement2_Cost").value;
var Easement3Cost = +getField("Easement3_Cost").value;
//Create values for comparison
var qualifier = 0;
var multiplier = 1;
var total1 = 0;
//See if load qualifies
if (Pole1p > 0 || Secondary1p > 0 || Primary1p > 0 || Pole3p > 0 || Secondary3p > 0 || Primary3p > 0){
qualifier = 1;
}
//Check if term matches
if(qualifier == 1 && term == 1){
multiplier = 1.5;
}
//Add up totals
total1 = (PoleCost1p + MeterCost1p + ServiceCost1p + XfmerCost1p + SecondaryCost1p + PrimaryCost1p + PadCost1p + PoleCost3p + MeterCost3p + ServiceCost3p + XfmerCost3p + SecondaryCost3p + PrimaryCost3p + PadCost3p + Windrow10Cost + Windrow15Cost + Windrow30Cost + Chip10Cost + Chip15Cost + Chip30Cost + Removal30Cost + Easement1Cost + Easement2Cost + Easement3Cost) * multiplier;
//Create value
event.value = total1;
That means that at least one of the values of those fields could not be converted to a number.
Hi,
try67 solution could be implemented something like :
var fieldNumber = (isNaN(this.getField("Text1").value)) ? 0 : this.getField("Text1").value;
obviously replacing Text1 with the field names;
Copy link to clipboard
Copied
That means that at least one of the values of those fields could not be converted to a number.
Copy link to clipboard
Copied
Hi,
try67 solution could be implemented something like :
var fieldNumber = (isNaN(this.getField("Text1").value)) ? 0 : this.getField("Text1").value;
obviously replacing Text1 with the field names;