Stefan Cameron on Forms
Building intelligent forms using Adobe LiveCycle Designer

Debugging Scripts

Here’s a simple tip that could make a huge difference in your ability to debug your scripts in Designer:

If you use the JavaScript language for a script, you can use the following function to output information to the JavaScript Console available in Acrobat Standard/Pro:

console.println("string");

When you preview your form in Designer or open it in Acrobat, you can use the “Ctrl + J” keyboard shortcut to display the JavaScript Console. Note that this feature is not available in Reader.

Anyone who has attempted to debug their script(s) in Acrobat knows that it’s a painful thing to do. Unfortunately, many only know about

app.alert("string");

or

xfa.host.messageBox("string");

which gets the job done but not without some headaches and, in certain cases, RSI in your index finger clicking through all those message boxes! The other problem is that showing a message box can cause differences in the form’s behaviour, especially if you’re trying to debug a script which is setting focus to an object on your form.

By using console.println, you can output text to the JavaScript Console so that you don’t change the behaviour of your scripts.

The ability to debug scripts is something we know needs serious attention in Designer and trust me, we’ve talked about it and we have plans to address these issues but I can’t speak about anything definite at this time.

Updated: August 5, 2008


Posted by Stefan Cameron on May 5th, 2006
Filed under Debugging,Scripting
Both comments and pings are currently closed.

7 Responses to “Debugging Scripts”

  1. stevex on May 5th, 2006

    Another technique I use is putting a text field on the form and using it as a debug output field – setting it’s text in the click event with the results of the code that’s handling the click, for example.

    It’s right in between app.alert and console.println – no RSI from closing the alerts, and no having to bring up the JavaScript console. But you do have to remember to remove this field (and the code that sets it) before you’re done with your form.

  2. Thomas Groenbaek on May 6th, 2006

    Hi Formbuilder

    Thanks for the tip with
    console.println(…);

    YES the scripting and debugging features in designer are limited and need more attention if Adobe wants the platform to be a serious choice for big solutions/companies.

    When you are used to code completion etc. from Visual studio, eclipse etc. you feel like you were set 5+ years back in time!

    /Thomas
    Jyske Bank – Denmark

  3. sravya on July 28th, 2008

    Hi Stefan,
    thank you very much for those wonderfull scripts and tips to us new bies. i tried to use console.println abut it doesnt show anything. do i need to set anything before i use the command.please advice me
    thanks

  4. Stefan Cameron on August 5th, 2008

    sravya,

    You’re welcome!

    When you preview your form in Designer or open it in Acrobat, you simply need to press “Ctrl + J” on your keyboard to see the JavaScript Console. If you’re using Reader, you won’t be able to see it since that feature isn’t available in Reader.

  5. Sandeep on May 28th, 2009

    Hello Stefan,

    Somehow the ctrl+j shortcut didnt work for me either. I had to keep my adobe reader open to capture any javascript errors to show them at the console. Once i hit the error, i keep the console open and use it from there to show my console.println script.
    i am using livecycle ES 8.2

  6. Stefan Cameron on May 28th, 2009

    Sandeep,

    I’m a little confused, mostly because you’re talking about Adobe Reader which shouldn’t have a JavaScript Console. The Console is only available in Acrobat.

    If you were actually talking about Acrobat, not Reader, then it’s probably a focus issue with the Console. I find in some cases it tries to remain on top of other windows and when the Acrobat window is closed (i.e. when you move away from the Preview tab in Designer), the Console may try to auto-hide itself. This behaviour often gets it into a state where it won’t show itself when you press “Ctrl + J”. To get it out of that state, I usually have to kill the Acrobat.exe process and then launch Acrobat again.

  7. Alex Krancevik on June 22nd, 2009

    Sometimes you need to do this:
    Right click on the page, in the Preferences window select JavaScript, be sure that the “Show console on errors and messages” field is checked and then OK.
    Doing this the console showed up even in Adobe Reader.
    Good luck!