Skip to main content
April 3, 2017
Question

Text Field Custom Calculation Script Won't Save/Stay Selected

  • April 3, 2017
  • 3 replies
  • 7273 views

I have a Text field named "MyField". I'd like to add a Custom Calculation Script to it. Every time I select the edit, enter the code, and then click OK, it does not save the code and then reselects the default "Value is not calculated" option. It will even happen in fields that I have already saved previously and that did once work. When returning to them sometimes, I will see the selection change from "Customer Calculation Script" to "Value is not calculated" as soon as I activate that Calculate tab. Does anyone have any idea what causes this and/or how to avoid/correct it. I have tried searching all over Google and can't seem to find anyone else that has brought up this issue.

3 replies

JR Boulay
Community Expert
March 29, 2025

[MOVED TO THE ACROBAT DISCUSSIONS]

Acrobate du PDF, InDesigner et Photoshopographe
try67
Community Expert
April 3, 2017

Yes, I've experienced it as well. Mostly when using one of the built-in functions for calculation/validation/keystroke/etc.

The code usually works, although it's not displayed in the window, though.

April 3, 2017

Yeah, I was hoping it would still work, but it doesn't seem to. It does appear to happen more often when I have multiple files open that share the same field names but are not actually connected... That is not *always* the case, though... I don't think.

Thom Parker
Community Expert
April 3, 2017

I've had the same thing happen before.

Are you using the default JS editor or an external editor? And does the doc contain a large number of related fields?

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
April 3, 2017

This is while in the form through the text field properties.

Thom Parker
Community Expert
April 3, 2017

Thank you very much for that response, Thom. I have slowly been picking up Java and Adobe over the past year and really do need to get into some sort of class for it. I will take your suggestions into account moving forward. If I learn more through trial/error, I will add what I can to this thread. Do you know of any other threads already started out there that might have some other "solutions" that I should avoid repeating, haha


As a matter of fact, I know exactly where you can find a wealth of information of Acrobat Scripting. But first, to be perfectly correct in our terms. The application is Acrobat, which is made by Adobe. And the internal scripting language for Acrobat is JavaScript.  Java is a completely different language, and unrelated in any way to JavaScript.  

This JavaScript is exactly the same language used in HTML.  The difference is the DOM, the Document Object Model, which is the set of objects that connect the language into the application. So the "Core" JavaScript is identical between HTML and Acrobat, but the DOM is very different. The point being that you can lean a lot about JavaScript from the tutorials at W3C, just as long as you stick to Core JavaScript. 

The top set of tutorials in the listing on the left are all core, here: JavaScript Tutorial

Here are a couple videos introductory videos on Acrobat specific JavaScript:

http://www.pdfscripting.com/public/images/Free_Videos/BeginJS_WhatsJS_Free_mp4.cfm

http://www.pdfscripting.com/public/images/Free_Videos/BeginJS_InAcrobat_Free_mp4.cfm

There also used to be a site dedicated to Acrobat users, www.acrobatusers.com

This site is no longer maintained, but all the info is still there. Here's a link to the listing of JS tutorials

https://acrobatusers.com/tutorials/filter/search&channel=tutorials&category=+13&tut_type=Video+OnDemand+Infographic+HTML…

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often