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.

Can JavaScript fire a LiveCycle submit event?

Avatar

Former Community Member
Hello,



I went down the road of attaining finer control over the user experience when submitting a form or document, things like aborting the submit if the user responds negatively to a popup warning. The common wisdom seemed to be, "Instead of the LiveCycle submit button you need to use a simple button, do whatever scripting you want to do, and as the final step use the Acrobat API event.target.mailDoc() method."



I've tried that, and it does indeed work. However, I feel like the LiveCycle Submit button has a little better handle on actually orchestrating the dispatch of the form. Most significantly, the LiveCycle Submit button provides the popup with a radio button choice between desktop email and browser email, which I think is an important feature. I don't get that with the Acrobat API event.target.mailDoc().



So, here is my point. I'm wondering if I can have both... provide a simple button that does whatever fine-tuned scripting I want to do, and THEN it causes a LiveCycle email submission to fire?
4 Replies

Avatar

Former Community Member
"Process Fields" in the object library uses a hidden submit button. The visible button fires the click event on the hidden submit button. Just add your logic in there.



Mind posting an example of your popup? I need a simple message with OK, Cancel and have not yet spent to effort of creating one.

Avatar

Former Community Member
Your hint is working for me perfectly.



Here is the example of a popup you requested.



var isOK = true;



[ do validating of various kinds, use isOK as the flag... ]



if (isOK)

{ var Mbox = xfa.host.messageBox

("Are sure you want to commit the form and email it?\n\n"+

"If you click OK, all fill-in fields will be closed to "+

"further changes, and the final result will be prepared "+

"for email.\n\n"+

"If you are not sure you are ready, click CANCEL to resume "+

"work on the form.\n\n"+

"Hint: Save a local copy before using the Commit button, "+

"and you will have the option to make future revisions on "+

"that copy.", "Confirmation", 2,1);

if (Mbox != 1) isOK = false;

}



if (isOK)

{ app.runtimeHighlight = false;

for (nPageCount = 0; nPageCount < xfa.host.numPages; nPageCount++)

{ oFields = xfa.layout.pageContent(nPageCount, "field");

nNodesLength = oFields.length;

for (nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++)

{ oField = oFields.item (nNodeCount);

sName = oField.name;

if (sName == "Up" || sName == "Down" || sName == "Insert" || sName == "Remove" || sName == "Spawn")

oField.presence = "invisible";

else if (sName == "Print" || sName == "Submit"); // No action

else oField.access = "readOnly";

}

}



/* Fire the hidden submit button */



parent.HiddenSubmit.execEvent ("click");

}

Avatar

Former Community Member
Sorry about the appearance of that. If you'd like to see the form as a PDF, send me your email address.

Avatar

Former Community Member
Got it, just needed this part:



var Mbox = xfa.host.messageBox

("Are sure you want to commit the form and email it?\n\n"+

"If you click OK, all fill-in fields will be closed to "+

"further changes, and the final result will be prepared "+

"for email.\n\n"+

"If you are not sure you are ready, click CANCEL to resume "+

"work on the form.\n\n"+

"Hint: Save a local copy before using the Commit button, "+

"and you will have the option to make future revisions on "+

"that copy.", "Confirmation", 2,1);

if (Mbox != 1) isOK = false;



I was looking at execDialog which is much more powerful, but complicated to use.