Copy link to clipboard
Copied
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!
I think the issue is with this part of the code:
new Date("01/"+v)
That is not how you instantiate a Date object. Run this code from the console and see what the output is:
new Date("01/02/2019")
You don't need to create a date object there at all... Just do it directly, like this:
var cDate = util.scand("dd/mm/yyyy","01/"+v);
Copy link to clipboard
Copied
I think the issue is with this part of the code:
new Date("01/"+v)
That is not how you instantiate a Date object. Run this code from the console and see what the output is:
new Date("01/02/2019")
You don't need to create a date object there at all... Just do it directly, like this:
var cDate = util.scand("dd/mm/yyyy","01/"+v);
Copy link to clipboard
Copied
When the date changed to 2/1/2019 in the first field today, all the fields populated today. Will this coding fix this issue?
Copy link to clipboard
Copied
It should do, yes.
Copy link to clipboard
Copied
I had my IT department revert my computer date to yesterday to work and it worked perfectly. Thank you!