Copy link to clipboard
Copied
Very new to this so appreciate the assistance!
My form has three subtotal fields
COREPOINTS
MGMTPOINTS
C_MPOINTS
If the MGMT POINTS field is 0, would like the C_M field to be 0.
If the MGMT POINTS field has a value, would like the C_M field to reflect COREPOINTS + MGMTPOINTS.
Thank you!
1 Correct answer
As the custom calculation script of "C_M" (or "C_MPOINTS"... Again, you've used both names), enter the following:
var v1 = Number(this.getField("MGMTPOINTS").valueAsString);
var v2 = Number(this.getField("COREPOINTS ").valueAsString);
event.value = (v1==0) ? 0 : v1+v2;
Copy link to clipboard
Copied
Is there a space between "MGMT" and "POINTS", or not?
Copy link to clipboard
Copied
Apologizes - typo on my part! Thank you..
Subtotal Field 1 named COREPOINTS
Subtotal Field 2 named MGMTPOINTS
Subtotal Field 3 named C_MPOINTS
If the MGMTPOINTS field is 0, would like the C_M field to be 0.
If the MGMTPOINTS field has a value, would like the C_M field to reflect the total of COREPOINTS + MGMTPOINTS.
Copy link to clipboard
Copied
As the custom calculation script of "C_M" (or "C_MPOINTS"... Again, you've used both names), enter the following:
var v1 = Number(this.getField("MGMTPOINTS").valueAsString);
var v2 = Number(this.getField("COREPOINTS ").valueAsString);
event.value = (v1==0) ? 0 : v1+v2;
Copy link to clipboard
Copied
Thank you! Sadly it didn't work .. am I doing something wrong?
Copy link to clipboard
Copied
Yes, you've not placed it under the correct location. Read my reply more carefully, please.
Copy link to clipboard
Copied
Thank you .. it works!! I am very appreciative!!
Copy link to clipboard
Copied
Reason I asked you in other post, what do you want if MGMT field is blank, because this type of code will show 0 in C_M when MGMT is 0 but it will also show 0 in C_M if MGMT is blank,if it doesn't bother you that way thats ok, but i think it would be better to make C_M blank when MGMT is blank.
Also this will just replicate whatever number is in MGMT field,you should make it to not show calculation until both fields have values.
Copy link to clipboard
Copied
https://www.pdfscripting.com/public/How-to-Write-a-Basic-PDF-Calculation-Script.cfm
Use the Acrobat JavaScript Reference early and often

