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

What is wrong with my form?

Explorer ,
Nov 05, 2018 Nov 05, 2018

Copy link to clipboard

Copied

I posted about this form a couple of weeks ago, and am still having trouble trying to figure out where my console errors are coming from.

It seems that most of my errors are stemming from three doc-level functions that I use often and in many different forms. I have never received error messages from these functions before. The functions are:

function no_zero() {

     if (+event.value) {

     //$ format for nonzero values

     AFNumber_Format(2,0,3,0,"$",true);

} else {

     //Don't show anything if result is zero

     event.value = "";

     }

}

function percent_zero() {

     if (+event.value) {

     //$ format for nonzero values

     AFNumber_Format(2,0,0,0,"%",false);

} else {

     //Don't show anything if result is zero

     event.value = "";

     }

}

function round(value, decimals) {

     return Number(Math.round(value + "e" + decimals) + "e-" + decimals);

}

I have checked and rechecked and there are no spelling issues when calling these functions through my form-fields. Yet I am still receiving error messages saying the functions are not defined. What's odd is I only receive the messages when I attempt to use any of the automation tools provided with Acrobat (i.e. Add Header or Footer, Watermark, Background, etc.).

Another point that I believe must be related:

Whenever I open this file, all of my calculated fields that should be suppressing values of zero, are displaying zeroes. See below screen grab (the "Sales Tax" line is the only line item that should be displaying a value of 0).

FORM_ZEROES.jpg

As soon as I change any value on the form, the zeroes disappear.

Thinking that maybe something in this form became corrupt, I rebuilt the entire thing last week. Much to my dismay it is still behaving strangely.

Thanks in advance for your time!

TOPICS
Acrobat SDK and JavaScript

Views

1.4K

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 ,
Nov 05, 2018 Nov 05, 2018

Copy link to clipboard

Copied

Where did you define these functions (e.g. document level script, folder level script, custom calculation script, ...)? What exactly are the error messages you are getting? Please quote them by copy&paste from the console window.

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
Explorer ,
Nov 05, 2018 Nov 05, 2018

Copy link to clipboard

Copied

Hi Karl,

All of the functions are defined as document level scripts. The functions no_zero() and percent_zero() are called from Field Format scripts, and the round() function is called from Field Calculation scripts. Here is a sample of the error messages I am receiving.

ReferenceError: no_zero is not defined

1:Field:Format

ReferenceError: percent_zero is not defined

1:Field:Format

ReferenceError: no_zero is not defined

1:Field:Format

ReferenceError: no_zero is not defined

1:Field:Format

ReferenceError: no_zero is not defined

1:Field:Format

ReferenceError: round is not defined

2:Field:Calculate

I also sent this form to another forum member who received the below errors (I don't quite understand why he received these and I have not - perhaps a setting I don't have turned on?), but each of these fields references one or more of the aforementioned functions.

Exception in line 1 of function top_level, script AcroForm:CUSTOMER_RATE:Format

Exception in line 1 of function top_level, script AcroForm:SCHED_A_VALUE:Format

Exception in line 1 of function top_level, script AcroForm:AMT_FINANCED:Format

Exception in line 1 of function top_level, script AcroForm:DEPRECIATION:Format

Exception in line 2 of function top_level, script AcroForm:FINANCE_CHARGE:Calculate

Exception in line 1 of function top_level, script AcroForm:PAYMENT_AMT:Format

Exception in line 7 of function top_level, script AcroForm:TOTAL_PAYMENTS:Calculate

Exception in line 1 of function top_level, script AcroForm:ACCUMULATED_DEPRECIATION:Format

Exception in line 1 of function top_level, script AcroForm:ACCUMULATED_DEPRECIATION:Format

Exception in line 5 of function top_level, script AcroForm:TOTAL_RENTAL_PRICE:Calculate

Exception in line 1 of function top_level, script AcroForm:PAYMENTS_TO_DATE:Format

Exception in line 1 of function top_level, script AcroForm:BUYOUT:Format

Exception in line 1 of function top_level, script AcroForm:AMT_PAID_TO_DATE:Format

Exception in line 1 of function top_level, script AcroForm:LEASE_AMT_LEFT:Format

Exception in line 1 of function top_level, script AcroForm:TOTAL_CASH_PRICE:Format

Exception in line 1 of function top_level, script AcroForm:TOTAL_SALE_PRICE:Format

Exception in line 1 of function top_level, script AcroForm:TOTAL_MONTHLY_PAYMENT:Format

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 ,
Nov 05, 2018 Nov 05, 2018

Copy link to clipboard

Copied

Can you share the form?

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 ,
Nov 05, 2018 Nov 05, 2018

Copy link to clipboard

Copied

I can't get an error with this form in Acrobat Reader DC or Adobe Acrobat DC.

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
Explorer ,
Nov 05, 2018 Nov 05, 2018

Copy link to clipboard

Copied

Thanks so much for taking a look. Ordinarily I'd say that's good news, but now I'm even more confused. When you opened it, did you see the zeroes incorrectly displayed as in the above screenshot?

Is it possible that some outside force is causing the errors on my end? Perhaps my operating system or some preference setting?

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 ,
Nov 05, 2018 Nov 05, 2018

Copy link to clipboard

Copied

I see the zeroes.

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
Explorer ,
Nov 05, 2018 Nov 05, 2018

Copy link to clipboard

Copied

Do you have any thoughts as to why that may be happening? I'm having a really difficult time trying to find a resource that can help me decipher this on my own. As I mentioned before, I use these functions in lots of forms and none of them have ever behaved this way.

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 ,
Nov 05, 2018 Nov 05, 2018

Copy link to clipboard

Copied

I don't know why you get the error messages.

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
Explorer ,
Nov 05, 2018 Nov 05, 2018

Copy link to clipboard

Copied

Error messages aside, I'm really concerned about the formatting scripts not working when the document is initially opened. Couldn't it be possible that that behavior is indicative of a larger issue?

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 ,
Nov 05, 2018 Nov 05, 2018

Copy link to clipboard

Copied

Format scripts don't get triggered when the file is opened, normally, only when the fields are edited.

Also, the second set of error messages you posted don't look like they're from Adobe 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
Community Expert ,
Nov 05, 2018 Nov 05, 2018

Copy link to clipboard

Copied

What version of Acrobat/Reader are you running, and on what operating system? What I usually do when I have weird problems, is to slowly strip away fields and scripts one by one from the form, so that I can isolate what is happening to just one or a few fields. That oftentimes makes it easier to see what's going on. If you want to share your form with me as well, please do so. I cannot promise that I can spend a lot of time on it, but I will definitely take a look.

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
Explorer ,
Nov 05, 2018 Nov 05, 2018

Copy link to clipboard

Copied

Karl Heinz Kremer Thanks so much for the offer - I will definitely send you a link to the form in a private message. I appreciate any time you can spare, but I totally understand that time is valuable! That is also great advice - I will try to start narrowing down what could be causing this craziness.

I am running Acrobat Pro DC on Mac OS High Sierra 10.13.6.

try67​ The second set of errors was from someone else who took a look at the form; and they certainly don't look like any I have ever seen, so that would make sense if they weren't derived from Acrobat.

I understand what you're saying about format scripts not being triggered when the file is open, but I'm still confused as to why I've never seen this behavior in any of the other forms I use these functions in. When I open any of those files, I don't see the zeroes as I do in this form.

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 ,
Nov 05, 2018 Nov 05, 2018

Copy link to clipboard

Copied

Yup, Try67 is right: Your scripts don't get executed when you open the form. You have zeros in these fields, and they remain in there until something in your form triggers a calculation. The easiest way to do that - and to get the zeros out of the form, so that next time you open it, it will look correct - is to open the JavaScript console and run the following command:

this.calculateNow();

Another command that will trigger the formatting scripts is

this.resetForm();

- this will however change the data in your form.

If you expect that something might update the form without refreshing the formatting in the fields, you can always call the calculateNow() method as the last command in your last document level script. As long as you don't do anything crazy in your scripts, that should however not be necessary once the fields look correct once. When you then save the form, everything will be formatted correctly when you open the form again.

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
Explorer ,
Nov 07, 2018 Nov 07, 2018

Copy link to clipboard

Copied

LATEST

Thanks so much for all of your help, and try67​ as well!! I've gotten rid of the zeroes, and I'm going to just hope that the error messages were a fluke.. I still get a couple when I use any of the automation tools, but it's not affecting my calculations so that's a start.

Thanks again!

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