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

Abort Submission via Email

mkenny
Registered: Sep 22 2011
Posts: 5

Hi, I have code that runs on the "enter" event of my submit button (a standard Button with a control type of "submit" and a "mailto:address [at] company [dot] com" URL). When the code runs, a pop up box opens, asking if the users want to continue when they click Submit.
 
However, the problem is if the user clicks "no" the form will still submit via email. I would like to add some code that if the user clicks no, the submission process should abort. Can someone provide this additional code?
 
I am using LiveCycle Designer ES and the code I am using for the submit button is:
var cMsg = "Please ensure that all fields are completed.\n\n"
cMsg += "Is this form ready to be submitted? \n\n"
cMsg += "Select YES to LOCK the form (this will also lock the Reset button). The Effective Date will be automatically be inserted.\n\n"
cMsg += "Do you want to Continue?\n\n"
var nRtn = app.alert(cMsg,1,2, "Lock Form?");
if(nRtn == 4)
 
Appreciate the assistance!
MJ

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

try
  1. ...
  2. if(nRtn == 4) {
  3. your send script here
  4. } else {
  5. xfa.event.cancelAction = 1;
  6. }

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

mkenny
Registered: Sep 22 2011
Posts: 5
Hi, no, that didn't work. It brought it straight to the submit email and bypassed the locking message.
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

hm, I could not reproduce the problem.
Tested my script in the enter and also click event and it worked.
  1. var nRtn = app.alert("Please ensure that all fields are completed.\n\nIs this form ready to be submitted? \n\nSelect YES to LOCK the form (this will also lock the Reset button). The Effective Date will be automatically be inserted.",1,2, "Lock Form?");
  2. if(nRtn == 4) {
  3. event.target.mailDoc({
  4. bUI: false,
  5. cSubject: "My form",
  6. cMsg: "My Message",
  7. cSubmitAs: "PDF"
  8. });
  9. }
  10. <javascript>

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

mkenny
Registered: Sep 22 2011
Posts: 5
Hi Radzmar,

First, thank you for all your assistance thus far. I tried your code, exactly as you have it, but when I click on the submit button, the message box does not pop open, and it brings me directly to the email to send. Is there a way that I can send you the form I am working on, so you could see first hand?

MJ