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

How to script a reaction to a user answer to a message box.

dk3dknight
Registered: Jan 22 2008
Posts: 136
Answered

What im trying to do is add a layer of "dummy" protection, what I have is a form it pulls a po number off of a database the user hits a button to remove the entry from the database.

*There was a want for a strange and unique numbering system by the parts clerk, I cheated with a excel document that generated all the numbers physically possible for the partsclerk's numbering system and dumped it into a access database.

I sense this numbering system will eventually fail and have voiced that but this is the system the clerk wants and her boss is backing her up so I comply.

What I have is a button that when the user clicks it, it removes the record so no one will use that PO again, that works just fine for what they want.

*cough* I had originally handed them a unique numbering system that was simple and required no thinking on there part but the clerk turned it down, it was something like date() + time() *cough*

I would also like to implement a simple message box similar to this..

xfa.host.messageBox("Are you sure you wish to delete this record from the database it cannot be undone.", "Delete Record Are you sure?", 2, 3)

Now if the user hits yes it deletes the record, and if the user hits no then it does nothing.

What I have not figured out how to do is capture the users response, ive read several tutorials and all references to messageBox in the livecycle scripting reference and this forums, and they all end at the end of the message box never mentioning really how to capture the user input i recall one that mentioned or made it sound possible but never really went further.

The version of Livecycle im using is: 8.05.2073.1.374024

Oh and apparently I like to also say the word "What" looking back over my post. :)

Thanks.

Chris "The evil form designer"

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You need to get the "XML Form Object Model Reference". This is the single most important document for LiveCycle scripting. You'll find it another documents here:

http://partners.adobe.com/public/developer/xml/topic.php

According to this document the message box fucntion returns an integer indicating the button the user pushed,

Quote:
Returns
A valid integer representing the value of the button pressed by the user:
● 1 (OK)
● 2 (Cancel)
● 3 (No)
● 4 (Yes)
But an easy way to find out is to simple try the code and display the return value in a field on the form, or in the console window.

http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/javascript_console/

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/]http://www.adobe.com/devnet/acrobat/[/url]

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

dk3dknight
Registered: Jan 22 2008
Posts: 136
Okay how about...

What is the return values name?

My use of the java console made things worse...
(in a "bad way" I had to blow the form away
thankfully it was on a new blank form, I would
never risk a production form)
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The "messagBox" function returns an integer in response to the user's selection. The integer represents the particular button the user pressed. So for example, in the code in your first post the message box will display Yes/No buttons. If the user presses "yes" then the function will return 4, if the user presses the "No" button the function will return 3. So you could write the code like this:

var nRtn = xfa.host.messageBox("Are you sure you wish to delete this record from the database it cannot be undone.", "Delete Record Are you sure?", 2, 3)if(nRtn == 4){... Do Yes thing ...}else{... Do No thing ...}

There's no need to test for the "No" case because there are only two ways to go, and it's the "yes" reponse that is of primarily interest.


The Acrobat JavaScript console is the most important tool for developing Acrobat JavaScript. You should go through the article and try out some of the examples. There is also a video on using the Console Window at www.pdfscripting.com

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/]http://www.adobe.com/devnet/acrobat/[/url]

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

dk3dknight
Registered: Jan 22 2008
Posts: 136
I discovered what went wrong with the java console, I had a extra entry in there that modified two textfields that worked in formcalc but when I moved to javascript they went to nova scotia.

Ill have to convert those entries to javascript wont be too hard.

Thanks thomp for your information and patience.