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

Pop up message on email button

Avatar

Level 2

I would like to create a pop up message that appears when users click on an email submit button. So far, I've tried to create a message using the Action Builder but that displays the message after the user has already been taken into their email and they end up sending the form off before they see the message. I would like the message to appear BEFORE the user is taken to their email package. Is there some scripting I can use in the presbumit event that ill enable me to do this?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

to show a message before the form is sent, you only need to add a messageBox script to the preSubmit event of any form object.

So you can use this event in a button, a subform or the root node (form1) for example.


form1::preSubmit:form - (JavaScript, client)


xfa.host.messageBox("You are going to send an email...", "A Message for You", 2, 0);


View solution in original post

4 Replies

Avatar

Correct answer by
Level 10

Hi,

to show a message before the form is sent, you only need to add a messageBox script to the preSubmit event of any form object.

So you can use this event in a button, a subform or the root node (form1) for example.


form1::preSubmit:form - (JavaScript, client)


xfa.host.messageBox("You are going to send an email...", "A Message for You", 2, 0);


Avatar

Level 2

Thank you - works great for most times I'd want to use it.

Problem is, for one particular form I'm working on, I have two submit buttons, and when I use the script, even though I set it on the 2nd email button, users still get the message when they click the 1st email button (which is in a separate subform and has a different name). Is there a way I can limit the message to just one button or because it is a presubmit script, will it always appear any time the form is submitted?

Avatar

Level 10

Hi,

you can use a global variable to control the appearance of the script,

First you have to initialize the variable (it's name is preSubmitMsg for example).


form1::initialize - (JavaScript, client)


preSubmitMsg = 0;



In the enter event of the send button you want to show the message add this script to change the variable.


form1.#subform[0].SendMailWithMsgButton::enter - (JavaScript, client)


preSubmitMsg = 1;



also add a script in its exit event, because the user may leave the button, without clicking it.


form1.#subform[0].SendMailWithMsgButton::exit - (JavaScript, client)


preSubmitMsg = 0;



Now add a if expression to the preSubmit script.


form1::preSubmit:form - (JavaScript, client)


if (preSubmitMsg === 1) {


  xfa.host.messageBox("You are going to send an email...", "A Message for You", 2, 0);


}



Finally reset the variable to it's initial value.


form1::postSubmit:form - (JavaScript, client)


preSubmitMsg = 0;



Avatar

Level 2

Thank you so much. Perfect. And thank you for the brilliant way you presented the answer - nice and easy to follow for a newbie like me and most importantly helps me understand WHY we are doing things that way.