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

Incremental dates in fields based on a manual date input in a "StartDate" field

New Here ,
Apr 02, 2019 Apr 02, 2019

Copy link to clipboard

Copied

I have this form with a start date that need to be manually input by the users. Based on that date, the fields 1 to 4 should be filled automagically with the "StartDate"+0,  "StartDate"+1, "StartDate"+2, "StartDate"+3, (...). How do I solve that with a Java script in Acrobat?

I'm thankfull for any help here!

/Getve

TOPICS
Acrobat SDK and JavaScript , Windows

Views

1.3K

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Apr 02, 2019 Apr 02, 2019

Use this code as the custom calculation script of your fields:

var startDateString = this.getField("StartDate").valueAsString;

if (startDateString=="") event.value = "";

else {

    var startDate = util.scand("dd.mm.yy", startDateString);

    startDate.setDate(startDate.getDate()+0); // change 0 to 1, 2, 3, etc. for the other fields

    event.value = util.printd("dd.mm.yy", startDateString)

}

If you're interested, I've also developed a (paid-for) tool that allows you to set up such calculations very easi

...

Votes

Translate

Translate
Community Expert ,
Apr 02, 2019 Apr 02, 2019

Copy link to clipboard

Copied

Use this code as the custom calculation script of your fields:

var startDateString = this.getField("StartDate").valueAsString;

if (startDateString=="") event.value = "";

else {

    var startDate = util.scand("dd.mm.yy", startDateString);

    startDate.setDate(startDate.getDate()+0); // change 0 to 1, 2, 3, etc. for the other fields

    event.value = util.printd("dd.mm.yy", startDateString)

}

If you're interested, I've also developed a (paid-for) tool that allows you to set up such calculations very easily: Custom-made Adobe Scripts: Acrobat -- Apply Automatic Date Calculation

Votes

Translate

Translate

Report

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
New Here ,
Apr 03, 2019 Apr 03, 2019

Copy link to clipboard

Copied

LATEST

Hi try67 & thanks!

Your code solved my challenge after a small adjustment. I changed startDate to startDateString in line 04 and 05 (as below) and voila; it worked!

var startDateString = this.getField("StartDate").valueAsString;

if (startDateString=="") event.value = "";

else {

    var startDateString = util.scand("dd.mm.yy", startDateString);

    startDateString.setDate(startDate.getDate()+0); // change 0 to 1, 2, 3, etc. for the other fields

    event.value = util.printd("dd.mm.yy", startDateString)

}

I'll certainly check out your tool if this scrifpting thing is getting a habbit... Again, thank you very much - brilliant!

Votes

Translate

Translate

Report

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