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.

Two functions on one submit button??

Avatar

Former Community Member
Is it possible to have a button perform 2 functions?

I would like to have one single button that when clicked will submit the form as pdf to an email address and also print the form to the default printer.

I have been able to have the button working for email OR print but not for the two.

When I add the JS code to the submit button to print the form the code is ignored.

The email dialog box shows and I can then send the email but the pdf is not printed.



Any help is appreciated,



FayeC
19 Replies

Avatar

Level 7
You do not use the "email" button. Just a plain button and you provide all of the code for printing and emailing.

Avatar

Former Community Member
I used a plain button and set it as submit. Added the email code to the Submit to URL field in the Submit tab.

I then added the JS print code to the object.



Still, the button only sends the email but doesn't print.

Should I add the email as JS code instead of using the submit tab?



FayeC

Avatar

Level 7
Print first. Don't use a submit button.



Aandi Inston

Avatar

Former Community Member
Hi Aandi,



That wasn't very clear. I am new to LiveCycle, please bear with me.

Did you tell me to use the print button and add the email code in JS to it?

If so, where can I find examples of this procedure?



Thank you in advance,



FayeC

Avatar

Level 7
No, neither a print button, nor a submit button. Just a button, which

runs the JavaScript code to first print, then submit, the form.



Aandi Inston

Avatar

Level 7
(By the way, I'm still not sure it will work, or is even possible,

though almost any two other functions could be combined this way).



Aandi Inston

Avatar

Former Community Member
Hi Aandi,



I had the button set to submit to email.

Can you point me to where I can find the correct code for the email submit in LC JS?



Thanks



fayeC

Avatar

Level 5
Here is JavaScript sample code, which might work when you customize.



Use just regular button and do not set it Submit or Email just leave it as regular.



try {

//email code

event.target.submitForm({cURL:"mailto:xxxxx@yyyyy.com?subject="+SubjectText.rawValue+"&body=Do not change subject line or body of this email. Just click on send to complete the first step of the process.",cSubmitAs:"PDF",cCharset:"utf-8"});



//Print code

xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 1, 0, 0, 0);



}catch (e) {

xfa.host.messageBox(""+e);

}

Avatar

Former Community Member
Hi SekharN,



I tried your code. Inserted it on a regular button as you instructed and it still doesn't work.

I edited the email path. Left the rest as you sent since I wasn't sure where to add the variable for the subject line.

I tested the form and the button doesn't do neither. No print or email.



I am getting a little frustrated with LC since the same function is easily accomplished in Acrobat but not in LC.



Any advice is appreciated.



FayeC

Avatar

Level 5
It is not a difficult task. I have done this kind of coding my self in many forms. If you do not mind can you email your copy of template at "meetsekharv at yahoo.com". I will try to fix it for you. Include brief description too.



SekharN

Avatar

Former Community Member
Hi Sekharn

I tried the same thing and didnt work!

Any ideas

Avatar

Former Community Member
Thanks for the code SekharN, I found it very useful.



Martin.

Avatar

Level 2
I have a similar issue - only I need the XML and the PDF to attach to the same email upon submission - any ideas?



Zoe

Avatar

Level 5
just an idea, will that work if you print XML to email Body text instead of attachment and attach PDF to the same email?

Let me know if that is an option. Be aware that the user can read and modify XML in this case before he/she click on email send button.

Avatar

Level 2
Thanks SekharN - I think I can propose that to the users, how would I achieve that?



Thanks!

Zoe

Avatar

Level 5
use this in a button click event.<br />//capture present XML in a variable<br />var printXML = xfa.data.saveXML();<br />//do the following if you want to print part of the XML<br />var startAt = printXML.indexOf("<SendXML");<br />var endAt = printXML.indexOf("</SendXML");<br />printXML = ""+printXML.substring(startAt, endAt+11)<br />//11 is length of the XML tag may have to adjust this based on<br />//end results.<br /><br />var subj = "email with XML and PDF";<br />//following composes email with PDF attachment<br />event.target.submitForm({cURL:"mailto:person@company.com?&body=following is the final XML<BR>"+printXML+"<BR>&subject="+subj,cSubmitAs:"PDF",cCharset:"utf-8"});<br /><br />Good Luck,<br />Sekahr

Avatar

Level 2
Exactly like you said - my users are having 'data integrity' issues with this solution. If it is in the body of the email, any idiot could change it, even if just accidently.



Any other suggestions?



Zoe

Avatar

Level 5
You could consider composing two emails one with PDF and other with XML attachment but again the drawback is user have to remember to click send button on two of the emails.



event.target.submitForm({cURL:"mailto:person@company.com?&body=XML Attachment&subject=XML Attachment", cSubmitAs:"XML",cCharset:"utf-8"});



event.target.submitForm({cURL:"mailto:person@company.com?&body=PDF Attachment&subject=PDF Attachment", cSubmitAs:"PDF",cCharset:"utf-8"});



Other alternative could be just composing one email with XML attachment and then recreate the PDF on the LiveCycle server using the XML received.

Avatar

Former Community Member

Hi Guys,

It's not possible to do something like this?

event.target.submitForm({cURL:"mailto:person@company.com?&body=XML Attachment&subject=XML Attachment", cSubmitAs:"XML","PDF"});

submiting the xml and the pdf in same e-mail instead of sending two e-mails?