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

Custom Calculation Script not producing anything

New Here ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

Hi!

I'm trying to create a calculated field that would display a calculated value based on values entered into two other fields in my document. If numbers are entered, it would produce a number. If nothing is added, it would stay blank. If N/A is written in the fields, then the same N/A would hypothetically appear in the calculated field. Whenever I preview and put test values into the two fields, nothing is produced in the calculated field. I'm not sure if I'm missing something here to get the value to show. Here's my code: 

 

var m = this.getfield(MEASURE1).value
var t = this.getfield(TEMP1).value
if (m === "" || t === "") {
event.value = ""
} if (m === "N/A" && t === "N/A") {
event.value = "N/A"
} else {
event.value = m / (2^((77-t)/27))
}

 

I'm relatively new to javascript in general, and same for Acrobat, so any help would be appreciated!

TOPICS
JavaScript , PDF forms

Views

710

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 ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

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
New Here ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

No errors appear

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 ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

That's not possible, since your code contains multiple errors. Do you know how to look for JS error messages in Acrobat?

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 ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

I only know the ones that would appear at the bottom of the console, but if there is another way to check I definitely don't know it. How would I go about that?

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 ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

Yes, that's the place (assuming you mean the JS Console). Do you not see any error messages there after you change the value of one of the 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
New Here ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

No, it let me select okay with no issue and no error messages. If you dont mind, what's wrong with the code? maybe thats whats stopping it from working?

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 ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

- There's no method called "getfield".

- You did not place the field names in quotes.

- The "^" symbol is not what you think it is in JS.

- Your first if-statement is irrelevant because of the second one.

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 ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

I used ^ because thats listed in acrobat as an operator, but im assuming its ** instead then. Ill try these tips out, thank you!

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 ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

You can't write code with guesses and assumptions. If you're trying to calculate X-to the power of-Y I suggest you google "JavaScript math power".

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 ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

Where did you see it listed?

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 ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

https://helpx.adobe.com/sign/using/calculated-fields.html is where adobe says to use '^' as an exponent operator

and ** is the operator for exponent in JS. Not assumptions or guesses, just contradicting information. I took a single course, day two working with it and am still learning, so you can understand where I got it wrong the first time. But thank you, I'll figure it out from here!

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 ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

LATEST

This article is about Adobe Acrobat Sign, not Adobe Acrobat. The names are similar, but the applications are quite different.

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