Skip to main content
Participant
November 5, 2021
Question

Custom Calculation Script - Set deadline date at least 5 working days after date of submission

  • November 5, 2021
  • 1 reply
  • 867 views

Hi all,

 

I have no basic knowledge of scripting and had only begun using Custom Calculation Script in Acrobat.

 

We have a Job Sheet that we have two Date fields on. One is the Date Submitted, and the other is Deadline. We need to have the Deadline date option to be at least 5 working/business days after the Date Submitted.

 

We currently have 

 

var s1 = this.getField("DATESUBMITTED_af_date").valueAsString; if (s1=="") event.value = ""; else { var d1 = util.scand("dd/mmm/yyyy", s1); d1.setDate(d1.getDate()+5); event.value = util.printd("dd/mmm/yyyy", d1); }

 

But this only sets the Deadline date 5 days after and there's no option to select a later date.


Any help would be much much appreciated!

 

Thanks!

This topic has been closed for replies.

1 reply

Participant
November 5, 2021

Sorry, this is how the current script looks and not the mess above.

var s1 =

this.getField("DATESUBMITTED_af_date").valueAsString;

 

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

 

else {

    var d1 = util.scand("dd/mmm/yyyy", s1);

    d1.setDate(d1.getDate()+5);

    event.value = util.printd("dd/mmm/yyyy", d1);

}

try67
Community Expert
Community Expert
November 5, 2021

Note this adds 5 days, not 5 working days. Doing that will require a more complex solution, especially if you want to skip holidays, too.

Participant
November 8, 2021

Hey @Nesa Nurani and @try67!

 

Thanks for the quick response. I think I may be putting Nesa's script in the wrong position and what happens is we're able to manually select a date on the second date field, but the +5 days condition isn't working.

 

The first date field is DATESUBMITTED_af

 

While the current script is under DEADLINE

 

Do you mean to say I should delete the current script as shown above, then paste your suggested script under "Run custom validation"?

 

Thank you!