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

Java in Livecycle Designer

willin2u
Registered: Sep 14 2009
Posts: 16
Answered

Has anyone created a fake email button to check for required fields then execute an event on a button?

I have a form where I have written Java programming on a button to email the form and include field names (see below):

var oDoc = event.target;
oDoc.mailDoc({
bUI: false,
cTo: "pnf [at] jeffersonregional [dot] com" ,
cBcc: "renee [dot] holtzman [at] jeffersonregional [dot] com; janice [dot] lenz [at] jeffersonregional [dot] com" ,
cSubject: "PNF for " + LastName.rawValue + ", " + FirstName.rawValue + " : Reason - " + ReasonforChg.rawValue + " (" + ReasonCodes.rawValue + ") "

I would like to keep this but have lost the check for required fields since I am not using it as a submit button. I am trying to create a button that checks for required fields then executes the script on the button to email the form.

Can anyone help me?

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
A manual validation could look like:

if (FirstName.rawValue == null || LastName.rawValue == null){xfa.host.messageBox("Please fill fields before submitting the form");}else{var oDoc = event.target;oDoc.mailDoc({bUI: false,cTo: "<span class="spamspan"><span class="u">pnf</span> [at] <span class="d">jeffersonregional [dot] com</span></span>" ,cBcc: "<span class="spamspan"><span class="u">renee [dot] holtzman</span> [at] <span class="d">jeffersonregional [dot] com</span></span>; <span class="spamspan"><span class="u">janice [dot] lenz</span> [at] <span class="d">jeffersonregional [dot] com</span></span>" ,cSubject: "PNF for " + LastName.rawValue + ", " + FirstName.rawValue + " : Reason - " + ReasonforChg.rawValue + " (" + ReasonCodes.rawValue + ") "}

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

PITTfan2
Registered: Sep 5 2009
Posts: 14
What if I have more than one field that is required? How do I add those fields like EmployeeNo., FirstName, EffectiveDate, to this field?
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Then you simply have to add the fields to the if expression of the script.

if (FirstName.rawValue == null || LastName.rawValue == null || EmployeeNo.rawValue == null || EffectiveDate.rawValue == null)

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

willin2u
Registered: Sep 14 2009
Posts: 16
I've tried it but it does not work. Is there somewhere on this forum I can attach the form so you can look at it?
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
You can upload the form somewhere in the www and post the link here.
I preffer www.acrobat.com for sharing pdf files but every other file share platform will be good enough too.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

PITTfan2
Registered: Sep 5 2009
Posts: 14
Here is the file.

https://share.acrobat.com/adc/document.do?docid=fcfaedde-7481-45a3-a06e-bea4beccff71
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Here is what I did.
On your FakeMail button I added the script I described before.
Works like a charm.

SeniorityDate.#subform[0].FakeEmail::click - (JavaScript, client)if (EmployeeNo.rawValue == null ||LastName.rawValue == null ||FirstName.rawValue == null ||EffectiveDate.rawValue == null){xfa.host.messageBox("Please fill out the mandatory fields first.");}else{if (DropDownList1.rawValue != null){RealEmail.event__click.submit.target = "mailto:" + DropDownList1.rawValue;RealEmail.execEvent("click");}else{xfa.host.messageBox("Please select a user from the dropdown!");}}

https://share.acrobat.com/adc/document.do?docid=0059ffea-34b1-4888-b3c9-6dedfb5bbf2c

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

PITTfan2
Registered: Sep 5 2009
Posts: 14
Would you mind looking at this one more time?

I do not want the Submit Form button to relate to the DropDownList1 at the bottom of the form - this drop down will be used only by the employees in our department.

I would like the Submit Form button to be set-up with To,BCC, and Subject with field references and text I have included in the subject. I really appreciate all the help. This is the only thing holding up my project.

cTo: "pnf [at] jeffersonregional [dot] com" ,
cBcc: "renee [dot] holtzman [at] jeffersonregional [dot] com; janice [dot] lenz [at] jeffersonregional [dot] com" ,
cSubject: "PNF for " + LastName.rawValue + ", " + FirstName.rawValue + " : Reason - " + ReasonforChg.rawValue + " (" + ReasonCodes.rawValue + ") "
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Accepted Answer
Hope this helps.

if (EmployeeNo.rawValue == null ||LastName.rawValue == null ||FirstName.rawValue == null ||EffectiveDate.rawValue == null ||ReasonforChg.rawValue == null ||ReasonCodes.rawValue == null){xfa.host.messageBox("Please fill out the mandatory fields first.");}else{var myDoc = event.target;var address_cTo = "<span class="spamspan"><span class="u">pnf</span> [at] <span class="d">jeffersonregional [dot] com</span></span>";var address_cBcc = "<span class="spamspan"><span class="u">renee [dot] holtzman</span> [at] <span class="d">jeffersonregional [dot] com</span></span>; <span class="spamspan"><span class="u">janice [dot] lenz</span> [at] <span class="d">jeffersonregional [dot] com</span></span>";var sub = "PNF for " + LastName.rawValue + ", " + FirstName.rawValue + " : Reason - " + ReasonforChg.rawValue + " (" + ReasonCodes.rawValue + ") ";var msgBody = ""; myDoc.mailDoc({bUI: false,cTo: address_cTo,cBcc: address_cBcc,bBcc: true,cSubject: sub,cMsg: msgBody,cSubmitAs: "PDF"})}

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

PITTfan2
Registered: Sep 5 2009
Posts: 14
Thank you so much for "hanging in there" with me on this form. The information you provided was very useful and works beautifully.

You have made my day.
willin2u
Registered: Sep 14 2009
Posts: 16
PITTfan2 wrote:
Here is the file.https://share.acrobat.com/adc/document.do?docid=fcfaedde-7481-45a3-a06e-bea4beccff71
Need your help again. Can't get the HR Use Only dropdown at the bottom right of the form to execute. Can you take a look at it and let me know if there is something wrong with the script. I just need the Send button to tell the user to select from the drop down if they haven't already and if they have already to send to the PDF.
dwissinger
Registered: Jul 18 2011
Posts: 1
Good Morning,

I have a form that our school wants to use for fundrasing. I have a drop down list which list all of our buildings. I need to create an email button so when a particular building is chosen it will email it to the principle of the building. I am not sure how to do this. Any help would be greatly appreciated. If you would like to see the form let me know.

Thanks in advance!

Denise Wissinger