Fairly simple calculation script and subsequent error

Community Beginner ,
Sep 03, 2018

Copy link to clipboard

Copied

Hi You fantastic debugger/educators!

Here is my script:

var vsupplycfm = Number(this.getField("SupplyCFMcalc").valueAsString);

var vexhaustcfm = Number(this.getField("iftheninflow").valueAsString);

var vnozzle = Number(this.getField("Nozzledropdown").valueAsString);

event.value = (13500*vnozzle) / (vsupplycfm+vexhaustcfm);

its a fairly simple calculation I want to run at the end.  And here is what the javascript debugger says:

Exception in line 3 of function top_level, script Field:Calculate

TypeError: this.getField(...) is null

3:Field:CalculateException in line 1 of function top_level, script Field:Calculate

TypeError: this.getField(...) is null

1:Field:Calculate

But the other fields are working and have numbers in them and are not null. I checked spelling , capitals etc seem correct.

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

111

Likes

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

Fairly simple calculation script and subsequent error

Community Beginner ,
Sep 03, 2018

Copy link to clipboard

Copied

Hi You fantastic debugger/educators!

Here is my script:

var vsupplycfm = Number(this.getField("SupplyCFMcalc").valueAsString);

var vexhaustcfm = Number(this.getField("iftheninflow").valueAsString);

var vnozzle = Number(this.getField("Nozzledropdown").valueAsString);

event.value = (13500*vnozzle) / (vsupplycfm+vexhaustcfm);

its a fairly simple calculation I want to run at the end.  And here is what the javascript debugger says:

Exception in line 3 of function top_level, script Field:Calculate

TypeError: this.getField(...) is null

3:Field:CalculateException in line 1 of function top_level, script Field:Calculate

TypeError: this.getField(...) is null

1:Field:Calculate

But the other fields are working and have numbers in them and are not null. I checked spelling , capitals etc seem correct.

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

112

Likes

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
Sep 03, 2018 0
Adobe Community Professional ,
Sep 03, 2018

Copy link to clipboard

Copied

Check again. Try copying & pasting the field names from the field properties dialog into the JavaScript editor.

You should also check that the denominator (vsupplycfm+vexhaustcfm) does not evaluate to zero before attempting the division, which will happen if both of those fields are blank.

Likes

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
Reply
Loading...
Sep 03, 2018 0