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

$host does not have a method messagebox error

scottsheck
Registered: May 3 2007
Posts: 138
Answered

I'm using livecycle designer 8.2 and during runtime, I get the Log error that:
 
$host does not have a method 'messagebox'.
 
I simply call:
 
xfa.host.messageBox("...")
 
using both of my formcalc and javascript events. They all are the correct case also.

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I believe you have a spelling error. The "B" in box has to be uppercase. The error message is showing a lower case "b".

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

scottsheck
Registered: May 3 2007
Posts: 138
I did use an uppercase B. I just pasted the error message incorrectly
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
There is no good explanation then. Host does have a function called messageBox. Is this an error being reported by FormCalc? or through a thrown exception in the console window?

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

scottsheck
Registered: May 3 2007
Posts: 138
No popup error displayed while running the form, it only shows the error in the log window of livecycle designer when in preview mode
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
How about when you run the form in Acrobat? Can you pinpoint the specific line of code that is generating the error?

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

scottsheck
Registered: May 3 2007
Posts: 138
I'm not sure how to pinpoint the line number using acrobat. Do I use the debugger console?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Use the console window. Take a look at the video link in my signature block.


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

scottsheck
Registered: May 3 2007
Posts: 138
I looked at the video and that was very good to know for future debugging, but it didn't help in my case because i finally found out it was my formcalc code that was causing the problem. Here is the line of code that is causing the error. When I comment it out, I don't get the error in livecycle. I don't see anything wrong with the code, do you?

if (xfa.host.version<8) then
xfa.host.messageBox("This PDF requires Adobe Reader version 8 or higher. You can download the latest version at: www.adobe.com/reader.")
endif

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I see nothing wrong with this code. And I tried it out in Acrobat 8. What version of Acrobat where you trying it in? What happens when you run it in the stand alone Acrobat/Reader?

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

scottsheck
Registered: May 3 2007
Posts: 138
I'm using Acrobat 9. Reader, Acrobat, and Livecycle all display the message properly when it needs to and also doesn't say it's a problem. The only place that says it's a problem is inside of Log Windows in Livecycle designer when you click the Preview tab.

Here's a way to duplicate it. Simply create a new pdf in livecycle. Then place this code in the initialize event of the form. Then you'll see the error in the log window. If I put it in the click event of a button, then I Don't see the error in the log window
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Try moving the code to the DocReady event. I've found that some of the Acrobat JavaScript functions and properties do not exist in the first initialize event. And even though xfa.host.messageBox seems to be a LiveCycle Scripting function, it is actually calling the alert function in the Acrobat DOM.

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

scottsheck
Registered: May 3 2007
Posts: 138
I appreciate your effort in helping me. I tried that event but it did't work unfortunately. Probably because I'm using Formcalc instead of javascript. But you gave me an idea. I used Javascript instead of Formcalc and kept it in the initialize event and now the error goes away! Problem solved. thank you so much for your help especially on the weekend!