Javascript - Date Auto-Population Help
A form that was previously working perfectly now seems to be giving me some grief with the New Year having come upon us. This form is set to start at the current month and go back one month concurrently as below:
1/2019 12/2018 11/2018 10/2018 9/2018
It was doing this until the new year of 2019 came up and now it's duplicating some dates and looks like..
1/2019 12/2018 12/2018 10/2018 10/2018
I'm looking for some help to fix this issue and get it back to the way it is meant to be updating.
Document level Javascripts are:
To get first field:
this.getField("Today").value = util.printd("mm/yyyy", new Date());
To get other fields:
function getPastDate(Today, months){
var v = this.getField(Today).valueAsString
if (v=="") return "";
var cDate = util.scand("dd/mm/yyyy",new Date("01/"+v));
if (cDate== null){
app.alert("Please enter a valid date of the form \"mm/yyyy\".")
return "";
} else {
cDate.setMonth(cDate.getMonth() + months);
return util.printd("mm/yyyy",cDate);
}
}
Field level Javascript:
event.value = getPastDate("Today",-1); results in 12/2018
event.value = getPastDate("Today",-2); results in 12/2018
Please help!
Thank you!
