Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Automatically calculate date for 30 days from a given date

Community Beginner ,
Sep 30, 2016 Sep 30, 2016

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:

Untitled-1.jpgFise pacienti intreg.pdf - Google Drive

TOPICS
Acrobat SDK and JavaScript , Windows
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 04, 2016 Oct 04, 2016

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);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 04, 2016 Oct 04, 2016

You need to clearly define when the file should have an automatic value and when it should not.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 04, 2016 Oct 04, 2016

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 04, 2016 Oct 04, 2016

Instead of a calculation script move the code to the doc-level and it will execute when the file is opened.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 05, 2016 Oct 05, 2016

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);

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 05, 2016 Oct 05, 2016

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);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 05, 2016 Oct 05, 2016
LATEST

Thank you man, it's working. Now I can modify the date whenever I need to

Bless you!!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines