Copy link to clipboard
Copied
I'm trying to create a custom calculation script in adobe acrobat pro to do the following:
Commencement date field - enter date
Term field - enter number of months - for example 6 months
End date - calculate by taking the commencement date and adding the number of months specified in the term field.
Here's what I currently have - the month changes depending on whats in the term field but for some reason it's added 4 year so to the end date. What do I need to change for this script to work. Many thanks in advance for any ones help 🙏🏼
var getMonth = this.getMonth("TERM"); var strDate = this.getField("COMMENCEMENT DATE").valueAsString; // Test for date format if (/\d{1,2}\/\d{1,2}\/\d{2}/.test(strDate)) { var dt= util.scand("dd/mm/yyyy", strDate); dt.setMonth(dt.getMonth()+getMonth); dt.setDate(dt.getDate()-1); event.value=util.printd("dd/mm/yyyy",dt) } else {event.value=""}
Copy link to clipboard
Copied
Try this:
change the name of variable getMonth.
Copy link to clipboard
Copied
The first line of your code doesn't make sense. If you're trying to access a field you need to use getField, and naming a variable the same as a method of the Date object is a bad idea, as was mentioned above.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now