Copy link to clipboard
Copied
I am creating a formula for retirement in adobe acrobat but I am not getting correct results.
=PMT(C17,C18,D16,-D13)
C17 is montly return rate
C18 is # of months until retirement
D16 is current savings
D13 is Amount needed in retirement
var rate = Number(this.getField("C17").value);
var nper = Number(this.getField("C18").value);
var pv = Number(this.getField("D16").value);
var fv = -Number(this.getField("D13").value);
var pmt = (pv * rate) / (1 - Math.pow(1 + rate, -nper)) + (fv / Math.pow(1 + rate, nper));
if (this.getField("C17").value === "" || this.getField("C18").value === "")
event.value = "";
else
event.value = pmt;
Copy link to clipboard
Copied
What exactly are you getting for the results? Why is it not correct? Where is this code placed?
Just to clean up your code, in the if statement use "==" instead of "===".
However, this probably will not change your result.
Copy link to clipboard
Copied
There is difference in result value. I have placed this code in D19 field in custom calculation script.
Copy link to clipboard
Copied
So some value is being calculated, just not the correct one?
In this case you will need to debug your calculation script.
To do this, copy the first 5 lines of your script to the console window.
Break the calculation into individual parts, and run them individually to find the issue.
Here's a video tutoial on using the console window.
https://www.pdfscripting.com/public/images/video/AcroJSIntro/AcroJSIntro_ConsoleWindow.cfm
Copy link to clipboard
Copied
I just noticed that I posted using my company account rather than my personal one. Could the administrators please delete my post? Thank you. @Thom Parker
Find more inspiration, events, and resources on the new Adobe Community
Explore Now