Copy link to clipboard
Copied
Hi there community! I'm back again with another question for you. I need a field in acrobat to automatically calculate 30 days from a given date. I've created a date field with the Date Picker Widget and I have another field that should calculate and show the date but with exactly 30 days in the future than the selected date from the first field. I hope you understand the explanation, my english skills aren't the best . I've uploaded the file and aslo here's a print screen of what I mean/need:
Copy link to clipboard
Copied
Ok, so I found the script for automatic future date calculation and is working flawlessly. Then I found the script to automatically insert today date in another field when opening the document but I'd like this field to be editable. It happens that sometimes I have to modify the current date to an older one but it seems that when I manually insert an older date and click outside the field the date returns to the present day.
This is how the script looks like:
var today = new Date();
event.value = util.printd("dd.mm.yyyy", today);
Copy link to clipboard
Copied
You need to clearly define when the file should have an automatic value and when it should not.
Copy link to clipboard
Copied
Well, when I open up the PDF file the "date" field will automatically be filled with the current date. Mostly this shouldn't be modified but it happens that, sometimes, I'll have to create this with another date and I need to be able to modify it and remain that way until I print the file. I'm only guessing that it has something to do with triggers option!
Copy link to clipboard
Copied
Instead of a calculation script move the code to the doc-level and it will execute when the file is opened.
Copy link to clipboard
Copied
Hi try67!
I guess I'm making a fool of myself but I just don't know how to move this line to "doc-level".
var today = new Date();
event.value = util.printd("dd.mm.yyyy", today);
Copy link to clipboard
Copied
You need to go to Tools - JavaScripts - Document JavaScripts and then create a new item there (call it "scripts") and paste the code into it.
However, you need to adjust it slightly. Let's say the name of the field is "Today". Use this code:
var today = new Date();
this.getField("Today").value = util.printd("dd.mm.yyyy", today);
Copy link to clipboard
Copied
Thank you man, it's working. Now I can modify the date whenever I need to
Bless you!!!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now