Expand my Community achievements bar.

SOLVED

Debugging tools and methods

Avatar

Former Community Member

I finally realized that unlike other programming environments, in Designer, when a script fails, it fails silently. It doesnt tell you where the fail point was (which line) or what type of error caused the problem (object type mismatch, undeclaired variable, etc.)

I eventually started shotgunning app.alert("error1") lines between every line of code, just to figure out which line in a particular secion was failing. There has got to be a better way than that!

So the question: Is there a way to enable/show runtime scripting errors, with information about the type of error, and on which line it occured?

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

The console will give you the line number of the error. See in the screen shot, the error is given then the line number, then the object that is calling the script that is causing the error.

screen1.png

And here is the associated script that is causing the error.

screen2.png

Paul

View solution in original post

6 Replies

Avatar

Level 10

Hi,

You can access the javascript console in Acrobat by pressing Control+J.

If you are having problems in your script you can insert the following:

console.println("a tag for what you are looking for: " + vVariable);

Then when previewing your form, the line is printed in the javascript console, together with the value (etc.)

Works very well for debugging and you don't have to keep clearing app.alerts.

Good luck,

Niall

Avatar

Former Community Member

I've gotten to the javascript console, but had no success getting it to show me anything useful.

Are there particular things you can do with that console that will show you errors or line numbers?

Avatar

Level 10

Hi,

If a script falls over it will tell you the object containing the script; the particular event; and in most cases why, for example something has no properties.

I don't think you can get it to give line numbers, but it wouldn't be the first time I was wrong. Unless you have a very long / complex script, I find that the indication of the problematic object / event is enough to target the issue.

Niall 

Avatar

Correct answer by
Former Community Member

The console will give you the line number of the error. See in the screen shot, the error is given then the line number, then the object that is calling the script that is causing the error.

screen1.png

And here is the associated script that is causing the error.

screen2.png

Paul

Avatar

Former Community Member

Thanks guys, that was exactly the information i was looking for.

Also, it seems like you do have to have the console window open already before you run  the script, so that was tripping me up for a while.

Avatar

Level 10

You can also use the button in LC's script editor that looks like a book with a checkmark - it will do basic syntax checking.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----