These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Can I add script to multiple fields? 'addScript' via Console?

Michael Frommer
Registered: Apr 3 2009
Posts: 80

I have a LCD form with multiple pages and 28 numeric fields on each page. I want to place a script (which calls a Script Object Function) in the Exit event of each field. I am hoping there is an easier way to do this than retyping the script in each and every field.

Is it possible to do this? I thought the Acro form 'addScript' function may be the solution but I can't seem to get it to work. Can this be done via a Console window, a batch file? (Write a .js file and run it in Windows?)

I've been trying to test it in a Console window (while the form is open in LCD) even just pointing to a single field, but I cant seem to get it to work. In fact I keep getting the error:

Console Error wrote:

NotAllowedError ; Security settings prevent access to this property or method.
Doc.addScript:4:Console undefined:Exec

[color=green]// var f points to a single field for test purposes[/color]
[color=green]// the addScript function parameter 'script name' is the function name used in the Script Object. I dont know how this parameter is applied/utilized since this is not an Acro form Document Level script[/color]

 
var f = "form1.P4.Tickets.TktMonDetails.Mon.M1";  
event.target = "f.event";    
f.event = "Exit";  
addScript ("TktDetailExit", "TktExitBehavior.TktDetailExit();");

Any help would be appreciated.

[color=blue]EDIT: Let me add that the form previously has Reader user rights enabled and now I am amending the form with additional pages. Could this have anything to do with the error message I get?[/color]

My Product Information:
LiveCycle Designer, Windows
Michael Frommer
Registered: Apr 3 2009
Posts: 80
Okay, I discovered that the error I was getting is usually related to a function not being trusted. So I have modified my code and I don't get the NotAllowedError anymore.

var f = "form1.P4.Tickets.TktMonDetails.Mon.M1"event.target = "f.event";f.event = "Exit";var myTrustedFunction = app.trustedFunction(function(addScript){app.beginPriv();addScript ("TktDetailExit", "TktExitBehavior.TktDetailExit();");app.endPriv():};

The console output is "Exit" but the script is not written to the document, at least not where I want it to be.

What have I done wrong in my code?