Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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);
}
Copy link to clipboard
Copied
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);}
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
Change "Date2" to "DEADLINE" and use it in "Run custom validation" of "DATESUBMITTED_af" field.
As try67 mentioned it will add 5 days but not 5 working days.
Copy link to clipboard
Copied
Ah that works now, thank you! I was just wondering (because this is what we're trying to avoid), would it be possible to disable the selection of dates earlier than +5 of "DATESUBMITTED_af"?
Thanks again!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more