Expand my Community achievements bar.

Scope of variables in read-only mode

Avatar

Level 2

Hello Experts/Enthusiasts

I have come across rather annoying "issue" (might be design decision made by Adobe) on Interactive Forms.

I have developed several script-heavy forms. Usual setup would be a form with XML schema, multiple WebServices and several Script Objects (layout functions, calculations, etc). At the top of most of the Script Objects I usually declare some public variables (arrays, boolean values etc). These variables are often shared across different Script Objects (using appropriate references). Problem is that when form is rendered in read-only mode (special mode set by Adobe Document Server during rendering) these variables does not seem to be stored in memory. What happens is that when I am calling one of the functions that is using these public variables script execution stops (undefined variable). It does not help that debug options of Interactive Forms pretty much do not exist (apart from using messageBox function to display results) but they are being limited even further in read-only mode (I have to display messages on text fields for instance).

Can anyone share some ideas on how can I make it work?

I know I can re-design functions so they will not use public variables but it will involve considerable effort (we are talking about hundreds or even thousands lines of code for some of the forms).

Regards

Michael

3 Replies

Avatar

Level 10

Hi,

As I understand it you are currently using script variables, which are declared and set within the script.

You can also use Global variables, which are setup in the File > Form Properties > Variables tab. You can assign values to these variables using the .value method in the script (eg not .rawValue).

Another approach would be to assign a vriable to an object's <desc> element, which I describe here: http://assure.ly/x1QObn.

Not sure if these will run in read-only mode.

Good luck,

Niall

Avatar

Level 2

Niall

Thanks a bunch for your suggestions (and blistering fast response), both look intriguing however they will require substantial changes to retro-fit them in my scripts so I think I am going to give it a miss for now. I might check these out when I will be designing some new form though.

I am still hoping that there is a way to "force initializing" of Script Objects in read-only mode so that all public/global variables will be accessible.

Anyone else have some idea(s) to share?

Regards

Michael

Avatar

Level 10

Instead of xfa.host.messageBox or using text fields for debugging try using console.println() instead then you can use the console window to monitor what's going on.