Copy link to clipboard
Copied
Hello,
I am currently trying to create a pdf that requires a few date boxes. I have a date box that automatically populates with the date when someone opens the form, but I need to make another box that calculates the date 2 weeks from the first date entered and then auto populate it onto the form. I have tried several versions of code and cannot seem to get any of them to work for me. Below is what I have been using and it doesn't come back with any errors but nothing actually auto populates on the pdf form when it opens so the script doesn't seem to be working. Please advise!
var startDate = this.getField("Today").value;
// Convert start date string to a Date object
var startDateObj = util.scand("mm/dd/yyyy", startDate);
// Calculate future date by adding 14 days
var futureDateObj = new Date(startDateObj.getTime());
futureDateObj.setDate(futureDateObj.getDate() + 14);
// Format future date as "YYYY-MM-DD" string
var futureDateString = util.printd("mm/dd/yyyy", futureDateObj);
Copy link to clipboard
Copied
You didn't set the result to show in a field.
Use this as custom calculation script in a field where you want to show new date:
var startDate = this.getField("Today").value;
var startDateObj = util.scand("mm/dd/yyyy", startDate);
if(startDate == "")
event.value = "";
else{
var futureDateObj = new Date(startDateObj.getTime());
futureDateObj.setDate(futureDateObj.getDate() + 14);
var futureDateString = util.printd("mm/dd/yyyy", futureDateObj);
event.value = futureDateString;}
Copy link to clipboard
Copied
You didn't set the result to show in a field.
Use this as custom calculation script in a field where you want to show new date:
var startDate = this.getField("Today").value;
var startDateObj = util.scand("mm/dd/yyyy", startDate);
if(startDate == "")
event.value = "";
else{
var futureDateObj = new Date(startDateObj.getTime());
futureDateObj.setDate(futureDateObj.getDate() + 14);
var futureDateString = util.printd("mm/dd/yyyy", futureDateObj);
event.value = futureDateString;}
Copy link to clipboard
Copied
Thank you so much, that worked beautifully!