Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

closing a form after a Javascript xfa.hostmessage box

Avatar

Level 2

I have a form with a checkbox that, when checked, displays an error message using Javascript xfa.hostmessage on the click event.  I would like the form to close after the user clicks "OK" on the Javascript Warning box.

I have tried adding an app.execMenuItem(Close); script after the xfa.hostmessage box script, but it did not work.  I also tried the app.execMenuItem(Close); script on the exit event of the checkbox, to no avail.

Is this even possible?  Any assistance is greatly appreciated.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

the massageBox method has a return value, you can use to determin, if the user has clicked OK or not.

if (xfa.host.messageBox("Close Doc?", "Close Doc", "2", "1") === 1) {

          event.target.closeDoc(false);

}

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

the massageBox method has a return value, you can use to determin, if the user has clicked OK or not.

if (xfa.host.messageBox("Close Doc?", "Close Doc", "2", "1") === 1) {

          event.target.closeDoc(false);

}

Avatar

Level 2

Thanks radzmar!  Works like a charm.

To clarify for everyone else, radzmar's script, when added to the click event after an xfa.host.messageBox, opens a second dialog box when the user clicks 'OK'.  The second dialog box asks if the user wants to close the document and allows for 'OK' or 'Cancel' to be selected.