Script not running at document open
I have the following script in my "Documents JavaScript." It is my understanding putting the script in "Documents JavaScript." should cause the script to execute each time the document is opened.
The intent is to look at three fields in a specific row... if all are $0.00 and a date has been put in the date field for that row, then remove the date. If any one of the three checked fields has a value >$0.00 then leave the date. The field is defaulted to currency, thus the Dollar sign. I have tried both with and w/o the "$." This is repeated 8 times as there are a possible 8 rows all with the fields as noted in the script.This is not working on testing. What am I missing or is this not going to work as is?
var v1 = this.getField("FUEL COST TOTAL1").value;
var v2 = this.getField("REEFER COST TOTAL1").value;
var v3 = this.getField("DEF COST TOTAL1").value;
var v4 = this.getField("DATE_FS1").value;
var v5 = this.getField("FUEL COST TOTAL2").value;
var v6 = this.getField("REEFER COST TOTAL2").value;
var v7 = this.getField("DEF COST TOTAL2").value;
var v8 = this.getField("DATE_FS2").value;
var v9 = this.getField("FUEL COST TOTAL3").value;
var v10 = this.getField("REEFER COST TOTAL3").value;
var v11 = this.getField("DEF COST TOTAL3").value;
var v12 = this.getField("DATE_FS3").value;
var v13 = this.getField("FUEL COST TOTAL4").value;
var v14 = this.getField("REEFER COST TOTAL4").value;
var v15 = this.getField("DEF COST TOTAL4").value;
var v16 = this.getField("DATE_FS4").value;
var v17 = this.getField("FUEL COST TOTAL5").value;
var v18 = this.getField("REEFER COST TOTAL5").value;
var v19 = this.getField("DEF COST TOTAL5").value;
var v20 = this.getField("DATE_FS5").value;
var v21 = this.getField("FUEL COST TOTAL6").value;
var v22 = this.getField("REEFER COST TOTAL6").value;
var v23 = this.getField("DEF COST TOTAL6").value;
var v24 = this.getField("DATE_FS6").value;
var v25 = this.getField("FUEL COST TOTAL7").value;
var v26 = this.getField("REEFER COST TOTAL7").value;
var v27 = this.getField("DEF COST TOTAL7").value;
var v28 = this.getField("DATE_FS4").value;
var v29 = this.getField("FUEL COST TOTAL8").value;
var v30 = this.getField("REEFER COST TOTAL8").value;
var v31 = this.getField("DEF COST TOTAL8").value;
var v32 = this.getField("DATE_FS8").value;
// Check to see if Date 1 is entered with no purchases
if (v1 == "0.00" && v2 == "0.00" && v3 == "0.00") {
v4.value = "";
}
// Check to see if Date 2 is entered with no purchases
if (v5 == "0.00" && v6 == "0.00" && v7 == "0.00") {
v8.value = "";
}
// Check to see if Date 3 is entered with no purchases
if (v9 == "0.00" && v10 == "0.00" && v11 == "0.00") {
v12.value = "";
}
// Check to see if Date 4 is entered with no purchases
if (v13 == "0.00" && v14 == "0.00" && v15 == "0.00") {
v16.value = "";
}
// Check to see if Date 5 is entered with no purchases
if (v17 == "0.00" && v18 == "0.00" && v19 == "0.00") {
v20.value = "";
}
// Check to see if Date 6 is entered with no purchases
if (v21 == "0.00" && v22 == "0.00" && v23 == "0.00") {
v24.value = "";
}
// Check to see if Date 7 is entered with no purchases
if (v25 == "0.00" && v26 == "0.00" && v27 == "0.00") {
v28.value = "";
}
// Check to see if Date 8 is entered with no purchases
if (v29 == "0.00" && v30 == "0.00" && v31 == "0.00") {
v32.value = "";
}
