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

Custom PDF script

New Here ,
Apr 06, 2021 Apr 06, 2021

Copy link to clipboard

Copied

Hi! I'm trying to do a very simple calulation using 3 fields to populate a 4th field, but I can't get anything to work. 

Field Name = "Base Fee 1"

Field Name = "Previously Invoiced 1"

Field Name = "Current Invoice 1" 

 

I'm trying to subtract the Previously Invoiced and the Current Invoice from the Base Fee to calculate the Remaining Fee. This is what I've tried or things similar to it:

 

var a = this.getField("Base Fee 1").value;
var b = this.getField("Previously Invoiced").value;
var c = this.getField("Current Invoice").value;
var d = a-b-c;
event.value = d.value;

 

Do you need to start with the brackets or function start or anything like that? I'm very new to all this so I'm just trying to piecemeal things I've found googling. 

 

Thanks for your help!

 

TOPICS
JavaScript , PDF forms

Views

403

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 , Apr 06, 2021 Apr 06, 2021

Replace

event.value = d.value;

with

event.value = d;

 

And check the Javascript console for errors.

 

Votes

Translate

Translate
Engaged ,
Apr 06, 2021 Apr 06, 2021

Copy link to clipboard

Copied

Here is a basic tutorial on calculation scripts.  It is pretty old but the info is still valid.

 

https://acrobatusers.com/tutorials/how-to-do-not-so-simple-form-calculations/

 

Unfortunately Adobe decided to not keep the download sample file that went with the tutorial.

 

Hope this helps,

 

Dimitri

pdfscripting_com 

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 ,
Apr 06, 2021 Apr 06, 2021

Copy link to clipboard

Copied

Replace

event.value = d.value;

with

event.value = d;

 

And check the Javascript console for errors.

 

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 ,
Apr 07, 2021 Apr 07, 2021

Copy link to clipboard

Copied

LATEST

Also make sure you have right field names,you write that your fields are "Previously Invoiced 1" and "Current Invoice 1"  but in your script there is no number 1 on those fields.

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