I have a few fields on my form that i want to combine and create a message and subject line from.
The fields are FirstName and LastName
Using those two i want a subject saying something like 'this is a completed form fro
firstName+lastName
And something similar to a message on the email. As well as cc their email so they get a copy of the form
Is this possible
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
In my original example I have a TextField object called subjectLine. If your form does not have this object then the script will fail, because Acrobat/Reader does not know what subjectLine is (eg it is undefined).
If you look at the original example I want to build a subject line in the email using the subjectLine TextField. Therefore I first test to make sure that the subjectLine TextField is not null.
Where in your case you should be testing that FirstName and LastName are not null, as these are the two objects that you are using to create your email subject line.
So for that part of the script this is what I would expect:
// Check subject line field and extend error message
if (form1.p1.subUserInformation.FirstName.rawValue == null || form1.p1.subUserInformation.LastName.rawValue == null)
{
errorMessage = errorMessage + "\n - please provide your first name and last name.";
}
else
{
vSubject = "Completed: Structure Change Form " + form1.p1.subUserInformation.FirstName.rawValue + " " + form1.p1.subUserInformation.LastName.rawValue;
}
Then the last block of script checks all of the options that are used to form the email and either sends the email if they are all not null or gives the user the error message:
// If fields required for script are null, warn user and do not initiate email
if (emailAddress.rawValue == null || form1.p1.subUserInformation.FirstName.rawValue == null || form1.p1.subUserInformation.LastName.rawValue == null)
{
xfa.host.messageBox(errorMessage, "Sending an email", 0, 0); // Send out a custom error message if any of these fields are null
}
else
{
// Everything is OK, send email
event.target.submitForm({cURL:"mailto: "+ vEmail +"?subject=" + vSubject +"&body=" + vBody + vCC,cSubmitAs:vFormat,cCharset:"utf-8"});
}
Does that make sense?
Niall
Views
Replies
Total Likes
Hi,
Yes, have a look at the third example on this form (if targeting version 8.1 and below of Acrobat/Reader): http://assure.ly/dYQFb4. The is also an example targetting Acrobat/Reader version 9.1 and above: http://assure.ly/hM2A5y.
Look at the script in the custom button at the bottom of the page.
Hope that helps,
Niall
Views
Replies
Total Likes
Yes, I looked at that solution but I am not really understanding it, I was hoping there was something simpler.
Views
Replies
Total Likes
Hi,
I have amended the script and created an example here: https://acrobat.com/#d=xWP6YZ63gkIHrUZjefmNcw
Hope that helps,
Niall
Views
Replies
Total Likes
Hi, your simplified script works but can you tell me what I did wrong with your more complicated one? Im just curious why it wasnt working
I got the message body to display correctly with what I want, however, the subject line won't work. I have tried all sorts of combinations and I get messages like null, null in the subject line or undefined and I just cant figure it out.
form1.p1.subSubmit.#subform[0].emailButton3::click - (JavaScript, client)
// First check if there are null values, then construct email using script
var vEmail;
var vSubject;
var vBody;
var vName;
var vCC = "";
var vFormat = subFormat.rawValue;
var errorMessage = "You have not provided enough information:";
// Check email address field and build error message
if (emailAddress.rawValue == null)
{
errorMessage = errorMessage + "\n - please provide an email address.";
}
else
{
vEmail = emailAddress.rawValue;
}
// Check if there is a cc email address inputted
if (ccEmail.rawValue != null)
{
vCC = "&cc=" + ccEmail.rawValue;
// vCC is put at the end of the mailto string because it starts with a &
}
// Check subject line field and extend error message
if (subjectLine.rawValue == null)
{
vSubject = "Completed: Structure Change Form" + " " + form1.p1.subUserInformation.FirstName.rawValue + " " + form1.p1.subUserInformation.LastName.rawValue;
}
else
{
vSubject = "Completed: Form" + " " + form1.p1.subUserInformation.FirstName.rawValue + " " + form1.p1.subUserInformation.LastName.rawValue;
}
// Check your name field and extend error message
if (yourName.rawValue == null)
{
errorMessage = errorMessage + "\n - please provide your name.";
}
else
{
vName = form1.p1.subUserInformation.FirstName.rawValue;
}
// Check message line field, if null build a custom body message
if (messageLine.rawValue == null)
{
vBody = "Hi, " + " \n\nAttached is a Structure Change Form completed by " + form1.p1.subUserInformation.FirstName.rawValue + " " + form1.p1.subUserInformation.LastName.rawValue + ". \n\nPlease double click the attachment to open our submission and review the data. \n\nThank you, \n\n" + vName;
}
else
{
vBody = messageLine.rawValue;
}
// If fields required for script are null, warn user and do not initiate email
if (emailAddress.rawValue == null || subjectLine.rawValue == null || yourName.rawValue == null)
{
xfa.host.messageBox(errorMessage, "Sending an email", 0, 0); // Send out a custom error message if any of these fields are null
}
else
{
// Everything is OK, send email
event.target.submitForm({cURL:"mailto: "+ vEmail +"?subject=" + vSubject +"&body=" + vBody + vCC,cSubmitAs:vFormat,cCharset:"utf-8"});
}
Views
Replies
Total Likes
Hi,
In my original example I have a TextField object called subjectLine. If your form does not have this object then the script will fail, because Acrobat/Reader does not know what subjectLine is (eg it is undefined).
If you look at the original example I want to build a subject line in the email using the subjectLine TextField. Therefore I first test to make sure that the subjectLine TextField is not null.
Where in your case you should be testing that FirstName and LastName are not null, as these are the two objects that you are using to create your email subject line.
So for that part of the script this is what I would expect:
// Check subject line field and extend error message
if (form1.p1.subUserInformation.FirstName.rawValue == null || form1.p1.subUserInformation.LastName.rawValue == null)
{
errorMessage = errorMessage + "\n - please provide your first name and last name.";
}
else
{
vSubject = "Completed: Structure Change Form " + form1.p1.subUserInformation.FirstName.rawValue + " " + form1.p1.subUserInformation.LastName.rawValue;
}
Then the last block of script checks all of the options that are used to form the email and either sends the email if they are all not null or gives the user the error message:
// If fields required for script are null, warn user and do not initiate email
if (emailAddress.rawValue == null || form1.p1.subUserInformation.FirstName.rawValue == null || form1.p1.subUserInformation.LastName.rawValue == null)
{
xfa.host.messageBox(errorMessage, "Sending an email", 0, 0); // Send out a custom error message if any of these fields are null
}
else
{
// Everything is OK, send email
event.target.submitForm({cURL:"mailto: "+ vEmail +"?subject=" + vSubject +"&body=" + vBody + vCC,cSubmitAs:vFormat,cCharset:"utf-8"});
}
Does that make sense?
Niall
Views
Replies
Total Likes
Ahhh yessss thats it! thank you once again.
If i want to add a phone number to the subject line I also add form1.p1.subuserinformation.phonenumber.rawValue right?
But if i want to keep the formatting to be (555) 555-5555 how do I do that? haha sorry.
Views
Replies
Total Likes
Hi,
Instead of using the .rawValue of the telephone field, use the .formattedValue.
This will bring in the data in the formatted display patterm
Good luck,
Niall
Hey! That worked, thanks Niall!
Views
Replies
Total Likes
This form is great, but I only needed the firstName, so I modified it, but now it doesn't work and I can't figure out why.... is it apparent to you? Thanks!
form1.page1.Button1::click - (JavaScript, client)
// First check if there are null values, then construct email parameters using script
var vEmail = "name@company.com";
var vSubject;
var vBody;
var vCC = "";
var errorMessage = "You have not provided enough information:";
// Check email address field and build error message
// Check if there is a cc email address inputted
if (emailAddress.rawValue === null) {
errorMessage = errorMessage + "\n - You must provide your email address.";
}
else {
vCC = "&cc=" + emailAddress.rawValue;
// vCC is put at the end of the mailto string because it starts with a &
}
// Check subject line field and extend error message
if (firstName.rawValue === null) {
errorMessage = errorMessage + "\n - please provide your first name.";
}
else {
vSubject = "This is a completed form from " + firstName.rawValue;
vBody = "Attached is a form from " + firstName.rawValue". \n\nThank you!";
}
// If fields required for script are null, warn user and do not initiate email
if (emailAddress.rawValue === null || firstName.rawValue === null) {
xfa.host.messageBox(errorMessage, "Sending an email", 0, 0); // Send out a custom error message if any of these fields are null
}
else {
// Everything is OK, send email
event.target.submitForm({cURL:"mailto: "+ vEmail +"?subject=" + vSubject +"&body=" + vBody + vCC,cSubmitAs:"PDF",cCharset:"utf-8"});
}
Views
Replies
Total Likes
Sorry, gone for the day/weekend - anyone else???
Niall
Views
Replies
Total Likes
Nevermind.... I figured that part out, but now I have the email button on a different page than the fields, so now it doesn't work again.......
Views
Replies
Total Likes
Go to assuredynamics.com and search for SOM Expressions. This might help in referencing objects on different pages.
N.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies