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

Auto populate dates of week

New Here ,
Apr 02, 2018 Apr 02, 2018

I'm building a form which populates the date fields for Monday through Saturday from the Sunday field "WENDING". The following custom calculation script is for the Saturday date field, but shows a "SyntaxError: missing ) after argument list".

var dayMs = 86400000;

event.value = util.printd("mm/dd/yyyy", util.scand("mm/dd/yyyy, this.getField("WENDING").valueAsString).getTime() - dayMs);

TOPICS
Acrobat SDK and JavaScript
701
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

correct answers 1 Correct answer

Community Expert , Apr 02, 2018 Apr 02, 2018

Adding milliseconds is tricky because of things like the change to/from daylight savings time, which mess it up.

A better approach is to do it like this:

var sundayString = this.getField("WENDING").valueAsString;

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

else {

    var d = util.scand("mm/dd/yyyy", sundayString);

    d.setDate(d.getDate()+1);

    event.value = util.printd("mm/dd/yyyy", d);  

}

Translate
New Here ,
Apr 02, 2018 Apr 02, 2018

I'm a beginner, so I'm not sure I'm using these methods correctly either

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 ,
Apr 02, 2018 Apr 02, 2018

Adding milliseconds is tricky because of things like the change to/from daylight savings time, which mess it up.

A better approach is to do it like this:

var sundayString = this.getField("WENDING").valueAsString;

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

else {

    var d = util.scand("mm/dd/yyyy", sundayString);

    d.setDate(d.getDate()+1);

    event.value = util.printd("mm/dd/yyyy", d);  

}

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
New Here ,
Apr 02, 2018 Apr 02, 2018
LATEST

Works like a charm, thanks!

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