Copy link to clipboard
Copied
I am trying to create a PDF form that will auto-populate an expiry date three years in the future from the current date in a created text field.
Text field name: ExpDate
Text field format: mm/dd/yy
So far I have entered the following into Page Properties --> Actions --> Add an Action (Trigger = Page Open, Action = Run a JavaScript):
var ExpDate = new Date();
ExpDate.setYear(ExpDate.getYear()+3);
var f=this.getField("ExpDate");
f.value=util.printd("mm/dd/yy", ExpDate);
This will produce the correct expiry date on the day that I make the certificate (i.e. it will read 06/07/16 on June 7, 2016), but when I open it the next day it will still ready 06/07/16 instead of 06/08/16. I am sure it is something simple that I need to change. Any ideas?
If it says "06/07/16" on June 7, 2016 that means it's not working correctly then, either, as it is not adding 3 years to the current date... It should show "06/07/19".
Are you seeing any error messages in the JS console (Ctrl+J) when you open the file?
Copy link to clipboard
Copied
If it says "06/07/16" on June 7, 2016 that means it's not working correctly then, either, as it is not adding 3 years to the current date... It should show "06/07/19".
Are you seeing any error messages in the JS console (Ctrl+J) when you open the file?
Copy link to clipboard
Copied
Hi try67,
Thanks for the quick reply! My apologies: "06/07/16" was a typo in my question. It should have read "06/07/19" in my question.
And, when I opened the file this morning... it worked!
For some reason, in my other attempts, I would look for the JS after the fact and it would be gone from the Action dialogue box. This time it stayed around. Woo-hoo!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now