Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Pop up message on email button

TarnG
Level 2
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
radzmar
Correct answer by
Level 10
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
radzmar
Correct answer by
Level 10
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

TarnG
Level 2
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?

radzmar
Level 10
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;



TarnG
Level 2
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.