• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Help with Custom Calculation Script

New Here ,
Feb 15, 2021 Feb 15, 2021

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!

 

 

 

TOPICS
Windows

Views

583

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 16, 2021 Feb 16, 2021

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;

Votes

Translate

Translate
Community Expert ,
Feb 15, 2021 Feb 15, 2021

Copy link to clipboard

Copied

Is there a space between "MGMT" and "POINTS", or not?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 16, 2021 Feb 16, 2021

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 16, 2021 Feb 16, 2021

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;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 16, 2021 Feb 16, 2021

Copy link to clipboard

Copied

Thank you!  Sadly it didn't work .. am I doing something wrong?

default8ylk0t09g43s_0-1613488056177.png

Screen2.PNG

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 16, 2021 Feb 16, 2021

Copy link to clipboard

Copied

Yes, you've not placed it under the correct location. Read my reply more carefully, please.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 16, 2021 Feb 16, 2021

Copy link to clipboard

Copied

Thank you .. it works!!  I am very appreciative!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 16, 2021 Feb 16, 2021

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 29, 2021 Dec 29, 2021

Copy link to clipboard

Copied

LATEST

https://www.pdfscripting.com/public/How-to-Write-a-Basic-PDF-Calculation-Script.cfm

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines