JavaScript Help Needed
Hello,
I have been working on designing a PDF where the first box auto generates the dates month in the format DD/YYYY, and the subsequent fields calculate in the same format, descending by 1 month increments from the date in the first field. The first box I have called Today, the subsequent boxes are listed as Today_1, Today_2, Today_3, etc. I.E.
02/2018 01/2018 12/2017 11/2017 10/2017
^This needs to auto generate to the current month, and then proceed to go back a month at a time for 105 boxes.
I thought I had this working, but I am getting a lot of errors now stating that..
InvalidSetError: Set not possible, invalid or unknown.
Field.value:1:Field Today:Format
The JavaScript causing this issue I am sure is one I have set as a Document Javascript which is:
function getPastDate(Today, months){
var cDate = util.printd("mm/yyyy",new Date(this.getField(Today).value));
var sDate = util.scand("mm/yyyy", cDate);
if ( sDate== null ){
app.alert("Please enter a valid date of the form \"mm/yyyy\".")
}else {
var pDate = new Date(sDate.getFullYear(),(sDate.getMonth() + months),sDate.getDate());
return util.printd("mm/yyyy",pDate);
}
}
In Today_1 in the Custom Calculate script, the script I am using to go back in 1 month increments is:
event.value = getPastDate("Today",-1);
Hoping to get some help I desperately need!
Thank you!
