I would like to edit the XML so that when the user clicks on an Email Submit button, the form is sent to an email address that the user has entered into a form field. I have seen code like this on the click event
event.target.submitForm({cURL:"mailto:"+name@domain.com + ? subject=This form: " ,cSubmitAs:"XDP",cCharset:"utf-8"});
but can I edit the XML so that the form is sent to the email address set in one field of the form?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Sean,
In my example I just used a textfield, as I wanted the ability to have multiple email addresses in the one field.
If you are using an email address custom object (which is fine), then you may need to amend the regular expression. For example the inbuilt RegExp for that object does not like ' in the address. I have added \\'\\ to allow this:
new RegExp("^[a-z0-9_\\-\\\\'\\.]+\\@[a-z0-9_\\-\\.]+\\.[a-z]{2,3}$");
You may need to amend the RegExp in a similar way to allow your email address pattern.
The second issue is that your format radio button group is likely to have specified values (1, 2,...) in the Object > Binding tab. Select the radio button group and untick the "specify values" checkbox. This will force the display values as the .rawValues. Should work then.
Good luck,
Niall
Views
Replies
Total Likes
Niall,Regarding documentation of LiveCycle ES2, I did a search with this result.Your search of Entire Site for SetFocusOnFirstFailedField.DoSetFocusOnFirstFailedField did not match any documents. Suggestions:I'd be very grateful if you knew of some sources of documentation and knowledge about ES2.Thank you.Sean
Views
Replies
Total Likes
Niall,The same search on Google produced only one hit: this forum!SeanSetFocusOnFirstFailedField.DoSetFocusOnFirstFailedFieldAdobe Forums: Sending email to a user-entered email...SetFocusOnFirstFailedField.DoSetFocusOnFirstFailedField(form1);. Good luck,. Niall. Report Abuse. Go to original post ...forums.adobe.com/message/3133592
Views
Replies
Total Likes
Hi Sean,
I haven't delved into these scripts until now. The functions are very similar to code that is auto generated by Action Builder (Tools menu).
Once the function is generated, it must be called somewhere. If you select the top node and in the script editor select "Events with script", the editor lists all scripts in the form. Control+F and search for the function name, brings up the object and event that calls the function.
Using auto generated functions to do the form validation is really neat, as it makes this new feature backward compatible.
I have updated the email buttons sample.
A word of caution. If you turn off the form validation feature in the properties dialog, LC Designer will remove the function and all of ITS calls to the function. It is unlikely to remove calls that you have put in, so events may fail because they would be calling a function that now doesn't exist.
Resources:
There is lots of help around - I would strongly recommend Creating Dynamic Forms with LC Designer by JP Terry - excellent!!
Also a book that doesn't deal with scripting at all but is very good is Forms that Work by Caroline Jarrett and Gerry Gaffney.
The Adobe PDF Forms Bible is okay, but mainly focuses on AcroForms.
Windjack Solutions have a subscription based service for solutions and scripts at http://www.pdfscripting.com. It has a lot of AcroForm script that can be amended to suit LC Designer and a growing library of LC Designer solutions.
Here are some online resources that you might find helpful:
http://www.adobe.com/go/learn_lc_scriptingBasics
http://www.adobe.com/go/learn_lc_scriptingReference
http://www.adobe.com/go/learn_lc_formCalc
http://www.adobe.com/devnet/livecycle/articles/Adobe_XML_Form_Object_M odel_Refer ence.pdf
http://www.adobe.com/devnet/acrobat/pdfs/lc_migrating_acrobat_xmlform. pdf
And a very handy resource (and while it is for version 6 it is still very good because of the way it is laid out): http://partners.adobe.com/public/developer/en/tips/CalcScripts.pdf
There are some solutions on the Adobe Cookbooks: http://cookbooks.adobe.com/livecycle_designer_es
Lastly, check out the Developer's Network on http://www.adobe.com/devnet/livecycle/ (the site has been updated and relaunched this week).
Good luck,
Niall
Views
Replies
Total Likes
SetFocusOnFirstFailedField.DoSetFocusOnFirstFailedField(form1); doesn't work on my form. I see the script object that you mentioned (below).
form1.#variables[0].SetFocusOnFirstFailedField - (JavaScript, client)
//+ GENERATED - DO NOT EDIT (ID:D3D1DC8E-1410-48E0-A345-031CA77F02CA CRC:1706013869)
//+ Type: SetFocusOnFirstFailedField
function DoSetFocusOnFirstFailedField(oRootSubform) {
if (xfa.host.name == "Acrobat") {
var oInvalidNodes = oRootSubform.getInvalidObjects();
var nCount = oInvalidNodes.length;
if (nCount > 0) {
xfa.host.setFocus(oInvalidNodes.item(0));
}
}
}
//-
Below is the script for the regular button. Is there something, perhaps, in the validation lines that prevents the setFocus from firing?
form1.page1.Button1::click - (JavaScript, client)
//validate required fields and show error messages if empty
//highlight required fields
regNumberTxt.mandatory = "error";
regNumberTxt.mandatoryMessage = "Please enter the Reg/Dist number.";
dsmNameTxt.mandatory = "error";
dsmNameTxt.mandatoryMessage = "Please enter the DSM name.";
monthEndDate.mandatory = "error";
monthEndDate.mandatoryMessage = "Please enter the Month end date.";
monthEndDate.mandatory = "error";
monthEndDate.mandatoryMessage = "Please enter the RSM approval.";
rsmEmail.mandatory = "error";
rsmEmail.mandatoryMessage = "Please enter the RSM email.";
// First check if there are null values, then construct email using script
var vEmail;
var vSubject;
var vBody;
var vCC = "";
var vFormat = subFormat.rawValue;
var errorMessage = "You have not provided enough information:";
// Check email address field and build error message
if (form1.page1.rsmEmail.rawValue != null)
{
vEmail = form1.page1.rsmEmail.rawValue;
}
// Check if there is a cc email address inputted
if (form1.page1.assocEmail.rawValue != null)
{
vCC = "&cc=" + form1.page1.assocEmail.rawValue;
// vCC is put at the end of the mailto string because it starts with a &
}
//Send email if fields are not null
if (form1.page1.rsmEmail.rawValue == null)
{
xfa.host.messageBox(errorMessage, "Sending an email", 0, 0);
}
else
{
if(form1.execValidate())
{
event.target.submitForm({cURL:"mailto: " + vEmail + "?subject= DSM and Associate Reward Form" + vCC, cSubmitAs:vFormat,cCharset:"utf-8"});
}
}
SetFocusOnFirstFailedField.DoSetFocusOnFirstFailedField(form1);
Views
Replies
Total Likes
Can you attach the updated version? Thank you.
"
I have updated the email buttons sample."
Views
Replies
Total Likes
Hi Sean,
It is the same link: https://acrobat.com/#d=tB03X0cr8fNGEEYfKazYgg
The call to the script object/function look good. However I placed it inside the last else statement. Have a look at the form and see does it work there for you.
Niall
Views
Replies
Total Likes
Niall,In the latest update of your form, this is what happens here. The first two buttons (submit types) do set focus on fail, while the third (regular button) does not. The color fields script does work in my form. I wonder why the setFocus is different. I also notice that when I adapte the code from your example (copied below), neither the setFocus nor the color fields works, and they don't work in your example, either. What do you see at your end?This is a new version of my form, building error messages as your latest example does. form1.page1.Button1::click - (JavaScript, client)// First check if there are null values, then construct email using scriptvar vEmail; //var vSubject; //var vBody; var vCC = ""; var vFormat = subFormat.rawValue; var errorMessage = "You have not provided enough information:"; // Check email address field and build error messageif (form1.page1.rsmEmail.rawValue == null){ errorMessage = errorMessage + "\n - please provide an email address."; }else{ vEmail = form1.page1.rsmEmail.rawValue; }// Check if there is a cc email address inputtedif (form1.page1.assocEmail.rawValue != null){ vCC = "&cc=" + form1.page1.assocEmail.rawValue; // vCC is put at the end of the mailto string because it starts with a &}// Check reg/dist number field and build error messageif (form1.page1.regNumberTxt.rawValue == null){ errorMessage = errorMessage + "\n - please provide the Reg/Dist number."; }else{ form1.page1.regNumberTxt.rawValue; }// Check month end date field and build error messageif (form1.page1.monthEndDate.rawValue == null){ errorMessage = errorMessage + "\n - please provide the Month end date."; }else{ form1.page1.monthEndDate.rawValue; }// Check DSM name field and build error messageif (form1.page1.dsmNameTxt.rawValue == null){ errorMessage = errorMessage + "\n - please provide the DSM Name."; }else{ form1.page1.dsmNameTxt.rawValue; }// Check RSM approval field and build error messageif (form1.page1.rsmApprovalTxt.rawValue == null){ errorMessage = errorMessage + "\n - please provide the DSM Name."; }else{ form1.page1.rsmApprovalTxt.rawValue; }//Send email if fields are not nullif (form1.page1.rsmEmail.rawValue == null){ xfa.host.messageBox(errorMessage, "Sending an email", 0, 0);}else{ if(form1.execValidate()) { event.target.submitForm({cURL:"mailto: " + vEmail + "?subject= DSM and Associate Reward Form" + vCC, cSubmitAs:vFormat,cCharset:"utf-8"}); } SetFocusOnFirstFailedField.DoSetFocusOnFirstFailedField(form1);}
Views
Replies
Total Likes
Hi Sean,
The version I posted on Acrobat.com was working here OK. But I have added its own else statement and reposted (https://acrobat.com/#d=tB03X0cr8fNGEEYfKazYgg). Works here fine
I didn't change the automated script/function at all. I just added a line to call it.
The reason that the colour failed fields works for the regular button is that this function is called from the initialise event of the form1. Therefore you don't need to call this from the button as the initialise event is fired already.
Niall
Views
Replies
Total Likes
Niall,Thank you for that screenshot. I see that you filled in two of the three required fields, so that the Your Name field was the only one left that was empty. In that case, the setFocus does indeed work. However, why doesn't it work if all the fields are empty? For example, if I fill in the Your Name field, but not the Subject field, no validation hints fire (no colored fields and no set focus. What should happen is that no matter which required fields are blank, those fields should be colored and the set focus should return to the first empty field. Am I correct in expecting this kind of behavior, or have I misunderstood something (Again!).Thank you for clarifying.Sean
Views
Replies
Total Likes
Hi Sean,
That's just the way the nested if statements are structured. The form validate execute command is only called if the minimum email fields are filled in. Also these fields were not set as mandatory, therefore do not form part of the validation.
If the user clicks the button without providing an email address or subject line, then a messagebox is called and the script finishes (without calling the form validation).
In your form you just need to look at where you validate in the process.
Hope that helps,
Niall
Views
Replies
Total Likes
Niall,I'll follow up on the comments you just posted, but in the meantime, I looked at the Report for your Example, finding these warnings.Target version does not support the Color Failed Fields option for form validation. Target Version Reader 9.1 Code 3005Target version does not support the Set Focus option for form validation. Target Version Reader 9.1 Code 3005Target version does not support the Show Dialog Message option for form validation. Target Version Reader 9.1 Code 3003Do these warnings suggest any possible problems with customizing a form?Thank you for your thoughts.Sean
Views
Replies
Total Likes
Good catch Sean,
Never checked it.
If opened in an earlier version it fails on the new event - validateState which was introduced in 9.1.
So while the form validation is driven through functions, it still requires the latest version.
Thanks,
Niall
Views
Replies
Total Likes
Niall,I'm indecisive right now. It seems as though the regular button cannot behave the way the Submit by Email button works. The regular button does not set focus on the first failed filed, no matter how many empty fields there are, whereas the Submit by Email button does this without fail. In your latest example form, what happens if you don't fill any of the required fields? I'm guessing that the setFocus doesn't work.My basic question, then, is "Can I have all the benefits of the Submit by Email button, and, in addition, have the benefits of the fully customizable regular button?Thank you for your thoughts.Sean
Views
Replies
Total Likes
Hi Sean,
The custom script (regular button) solution started out as a custom error message and then we added the new form validation handling features in v9.1. So it was trying to be everything to everyone.
So I have split it down.
Here is a version that will work in earlier versions of Acrobat/Reader, as it has a custom error message in the script and does not rely on validateState:
https://acrobat.com/#d=M3oe*KTVPuco6zeZoMg6Vg
I then stripped out the custom error message in the script and for this version rely solely on the new form validation handling. This requires the users to have Acrobat/Reader v9.1:
https://acrobat.com/#d=W72hKORXoOt0CAeKEJUuqQ
You need to look at the user population and decide on the minimum target version. Both versions work, however the v9 version has better error handling capabilities.
One advantage of the regular button approach is that you have full control over the actual submission. For example the format radio buttons (PDF/XML) now checks if the user has Reader and changes the format to XML.
Good luck,
Niall
Views
Replies
Total Likes
Niall,Thank you for this explanation. It helps me understand what's behind the behavior I've been seeing. It's very interesting to hear what you say abou the format radio buttons. What a great feature! I'm going to look into how that works.Now I'll take a good look at the new examples you sent. Thank you very much for those.I very much appreciate all your help. I feel much more secure in my understanding of ES2 now.See you in the forums.Sean
Views
Replies
Total Likes
Hey I dont get it. I need what the third button does. Let user send to my mail adress but also let him input his mail into CC text field so he can get the copy. But when i click the button nothing happens. i also tried putting in onto the server and still nothing. the above two buttons just open my thunderbird.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies