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

Custom Adobe Script Not Working

New Here ,
Mar 21, 2023 Mar 21, 2023

Hi, this is the first time that I have attempted to write a custom java script and something isn't working right.

I need to calculate one filed * 600, and this is what I have so far:  event.value = Number(this.getField("# of Wells").value*600).value;

Norine28990948d4zj_0-1679415861981.pngexpand image

 

Data is not showing up and I'm not sure if my script is even working.

 

Also I have another field that isn't working.  There is no data and I'm not sure if the script is working:  I need the different from "Total New..." and "Previous...":  var nDiff = this.getField("Total New Annual Rental").value=this.getField("PreviousRental").value-("PreviousRental");

 

Norine28990948d4zj_1-1679415961405.pngexpand image

 

Any assistance you can provide would be greatly appreciated.

 

 

 

TOPICS
JavaScript , PDF forms
932
Translate
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 ,
Mar 21, 2023 Mar 21, 2023

1. Use this:

event.value = Number(this.getField("# of Wells").value)*600;

2. Use this:

event.value = Number(this.getField("Total New Annual Rental").value)-Number(this.getField("PreviousRental").value);

 

Edited: Your field names were not clear in #2... I hope I got it right.

 

Translate
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 ,
Mar 21, 2023 Mar 21, 2023

Thank you, but for some reason the field is still blank:

 

Norine28990948d4zj_0-1679417557419.pngexpand image

 

I also had another example of an issue.  I think you did ask about my field names, they are "# of wells" and the output is "Additional Well Payment"

Norine28990948d4zj_1-1679417650410.pngexpand image

 

 

Translate
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 ,
Mar 21, 2023 Mar 21, 2023

JS is case-sensitive, so if the field is called "# of wells" it must appear like that in the code, not as "# of Wells"... An error message saying getField returned null should have appeared in the JS Console. Did you check it?

Translate
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 ,
Mar 21, 2023 Mar 21, 2023

Thank you!!  Everything is working now.

Translate
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 ,
Mar 21, 2023 Mar 21, 2023

I spoke too soon.  I'm in a bit of circular reference scenario...in my field for "Additional Well Payment", I need it to calculate as a total in another field, and I just used the simple "value is the sum" and picked the fields.  The issue is that "Additional Well Payment" is calculating if there is a value in the "# of wells" field, if I delete the value, then amount calculates and additional well payment goes to 0.  I attached the document to make it easier.

Translate
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 ,
Mar 21, 2023 Mar 21, 2023

You need to fix the fields calculation order.

Translate
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 ,
Mar 22, 2023 Mar 22, 2023
LATEST

Thank you!  When I used the automatic "pick" feature, it alphabatizes it.  I did a custom and it worked!

You rock!  I've never written java before, and with a lot of googling and your help, I feel confident now!

Translate
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