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

Custom Calculation to set date based on another date field

New Here ,
Nov 07, 2018 Nov 07, 2018

Copy link to clipboard

Copied

I'm working with two date fields.  When a date is entered into the first field(LeaseStart_af_date), I need the second field(BillStart_af_date) to display the 1st day of the month following.

So, if Lease Start date is 11/07/2018

Bill Start should be 12/01/2018

I'm using a custom calculation script for BillStart_af_date but it is not calculating.  The field 'LeaseStart_af_date' does not use any calculation.  Neither field is validated.  Both fields have format set to 'Date mm/dd/yyyy'.  I'm sure its an error with my script.  Any help would be appreciated.

var d = util.scand("mm/dd/yyyy",this.getField("LeaseStart_af_date").valueAsString);

if (d.getMonth() == 11) {

    d.setMonth(0);

    d.setFullYear(d.getFullYear() + 1);

}

else {

    d.setMonth(d.getMonth() + 1);

    d.setDate(1);

}

TOPICS
Acrobat SDK and JavaScript , Windows

Views

1.1K

Likes

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 , Nov 07, 2018 Nov 07, 2018

You're not applying the value to the field... Add this line at the end of your code:

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

Likes

Translate

Translate
Community Expert ,
Nov 07, 2018 Nov 07, 2018

Copy link to clipboard

Copied

You're not applying the value to the field... Add this line at the end of your code:

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

Likes

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 ,
Nov 08, 2018 Nov 08, 2018

Copy link to clipboard

Copied

LATEST

Thank you so much.  Gosh - I can't believe I missed that.  Works perfectly.

Likes

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