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

Accessing text in an event

formman
Registered: Jul 17 2008
Posts: 44

Greetings!

I have a real good one here for everyone to chew on:

I want to be able to access the text (sometimes //Comments or maybe even JavaScript or FormCalc statements) that are entered in the Script Editor and stored in a specific event.

I want to access this text from a script object or another field on the same form.

Anyone have an idea of what the JavaScript or FormCalc code would be to do that?

Please feel free to ask questions if needed.

Thanks in advance,

Rick Kuhlmann

Forms Developer/Designer
Tech-Pro, Inc.
Roseville, MN

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
That's easy. All of the XML is availible to the scripting model. If you can see it in the XML View in LiveCycle Desigener you can access, and possibly maniuplate it with JavaScript at runtime. For example, if I had button named "Reset" then I could get to a script on that button with this code.

xfa.form.form1.resolveNode("$..Reset.#event.script").value;

If I wanted to get all event scripts in the form:

xfa.form.resolveNodes("$..#event.script");

This code returns a node collection.

You should read both the XML SOM reference and the XML Form Object Reference:
http://partners.adobe.com/public/developer/xml/topic.php


Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

formman
Registered: Jul 17 2008
Posts: 44
Thanks Thom!

I also figured out you can just call:

TextField1.event_preSave.script.value you can get the exact script you want.

Thanks again.

Rick

Forms Developer/Designer
Tech-Pro, Inc.
Roseville, MN

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I didn't know that one. Where did you see it? Is it FormCalc or JavaScript?

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

formman
Registered: Jul 17 2008
Posts: 44
It was in JavaScript.

All I did was start typing TextField. and the JavaScript helper window (my name for it) came up and when I started typing "event" it popped up event_preSave which is where I had the code.

So basically pretty easy.

Rick

Forms Developer/Designer
Tech-Pro, Inc.
Roseville, MN

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Wow, I alreay tried that in LC 8.2, and tested the code you posted in Acrobat Pro 9.3 with no luck. On my system it doesn't recognize the "event_" prefix. I also did some searching on the Adobe site with no results. It's possible you have a later version of LC? Or something special? Perhaps a setting somewhere?

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi Thom,

I have the same feature in Designer (8.2).
The script editor automatically populates this method for all events of a form object where a script has been placed.
This works for JavaScript and FormCalc.

https://acrobat.com/#d=bYQOFdiI0hjQooomwNlkBw

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Very interesting. I don't have that feature:(

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Thom,

this feature can be enabled in the options dialog box under the Workspace tab.
It's called "Show Statement Completion Options".

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You misunderstand. I already use statement completion. But I do not get "event_" properties popping up. If I manually enter "event_click" for example, the code reports an error because "even_click" is an invalid property. The fact that it works for you means that there is something very different about your version of Acrobat/Designer. For example, maybe I haven't done the latest update. And it also points to an issue with using such a property, i.e., compatibility with earlier versions.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script