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

}

Nesa Nurani
Community Expert
Community Expert
November 5, 2021

If you want to be able to change date manually in second date field (lets call it "Date2") use script in "DATESUBMITTED_af_date" as validation script and not custom calculation, and set "Date2" field to have date format also.

Something like this:

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