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

Scripting For AutoFill Of Email Subject/Body Using Form Data - Adobe Designer 7

aehare70
Registered: Dec 11 2007
Posts: 12

I am using Adobe Designer 7. I want to be able to populate the Subject and Body of the email message that is created when the user clicks on the [Submit By Email] button. I would like be use form fields filled in by the user prior to them clicking the button.

My Product Information:
Acrobat Pro 7.0.0, Windows
pddesigner
Registered: Jul 9 2006
Posts: 858
This example demonstrates how to email a form to an address specified by the person filling the form.

Instructions
1. Add a text field for entering the email address
2. In the Object properties of the Submit button click the Submit tab
3. In the submit to box, enter a subject
Example: mailto:info [at] yourwebsite [dot] com?subject=Information RequestWhen the email button is clicked. An email message is displayed with the specified address.
Note: Specify the button as a submit button before typing the preSubmit event. The script will point to the first element specified for the button.

Script - validate event of TextField1

var address = new RegExp();
address.compile("^[a-z0-9_\\-\\.]+\\@[a-z0-9_\\-\\.]+\\.[a-z]{2,3}$","i");
var result = address.test(this.rawValue);
if (result == true){
true;
} else {
false;
}

Script - click event of the email button

this.resolveNode("#event").submit.target = "mailto:" + TextField1.rawValue + "?
subject=email data

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

aehare70
Registered: Dec 11 2007
Posts: 12
Thank you for your reply. That example probably works great for populating the address, but I am wanting to populate the SUBJECT and the button functionality must remain intact - thus "Submit By Mail". How would I be able to alter the subject line via user input from the form?
brennanhobart
Registered: Oct 9 2007
Posts: 37
pddesigner,

If you change the submit button control type to Submit, there is no option for entering this.resolveNode("#event").submit.target = "mailto:" + TextField1.rawValue + "?
subject=email data in the click event. The click event is not present. Is there another event that this script would work in? Thanks, Brennan
mjolnir
Registered: Apr 8 2008
Posts: 7
aehare70, have you had any success scripting to the subject line?
mike.ewins
Registered: Jun 23 2008
Posts: 4
To correct pddesigner's example:

Add a Button NOT an Email Submit button.

On the Button set the Control Type to 'Submit'

On the 'Submit' tab enter 'mailto:info [at] yourwebsite [dot] com?subject=Information Request' in to the 'Submit to URL' box.On the preSubmit event of the Button add the following code:

this.resolveNode("#event").submit.target = "mailto:info [at] yourwebsite [dot] com?subject=" + TextField1.rawValue;NB: Substitute your email address for 'info [at] yourwebsite [dot] com'When you submit your email address will be populated and the subject will be set to the text in TextField1.

If you want to populate both email address and subject use the following code:

this.resolveNode("#event").submit.target = "mailto:" + TextField1.rawValue + "?subject=" + TextField2.rawValue;

NB: TextField1 contains the email address and TextField2 contains the Subject.

Hope this helps.
Runolfr
Registered: Oct 1 2008
Posts: 119
Hate to resurrect an old thread, but I've been trying to do something like this all day. Unfortunately, the code in this thread doesn't actually seem to do anything at all. Does it need to be different for Designer 8.2?
mike.ewins
Registered: Jun 23 2008
Posts: 4
I'm using 8.1, so I don't think it will be a version issue.

Sorry - I'm not sure of your experience level so excuse me if my comments are too basic.

By default, the form code is set to run as Formcalc - this is JavaScript code so this must be changed.

The bigger assumption in the example above is that the Button and TextField1 and TextField2 fields are all within the same subform. On a well designed form this is unlikely to be the case. So, the TextField1 and TextField2 fields will need to be qualified with their subform location. For example, if your form has two contiguous subforms called Sub1 and Sub2, and the Text fields are in Sub1 and the Button in Sub2, you must qualify the field references in the code with 'Sub1.' e.g., Sub1.TextField1.

Hope this helps - let me know if you still have a problem.
Runolfr
Registered: Oct 1 2008
Posts: 119
I did have it set for JavaScript, but I didn't have the field name fully qualified. Once I specified the subform, it work. Many thanks!

You would happen to know how to specify the filename for the PDF file attached by the form, would you? Right now, Adobe randomly generates a unique identifier, and I don't know how to change that (I really am quite new to this).
Runolfr
Registered: Oct 1 2008
Posts: 119
A new puzzle. I have three forms, and the code to modify the subject line works perfectly in two of them. In a third, it does nothing at all. As far as I can tell, I've got the naming correct, but it's as if the line to modify the subject line doesn't exist.

// Specify email subject line
this.resolveNode("#event").submit.target = "mailto:name [at] comany [dot] com?&subject=Routine/Specialty Referral, MemberID: "
+ ReferralInformation.MemberID.rawValue;

... works.

// Specify email subject line
this.resolveNode("#event").submit.target = "mailto:name@comany?&subject=Position Fill Request, Title: "
+ PositionInformation.PositionTitle.rawValue;

... doesn't work, and I have no idea why not.
mike.ewins
Registered: Jun 23 2008
Posts: 4
Re the filename - I don't know.

Re your new puzzle - the syntax is identical, so it must be another problem. Does the structure of the 2nd form (in terms of subform hierarchy) differ from the first? My guess would be that you haven't qualified the field 'PositionTitle' enough. For the example above to work, the 'PositionInformation' subform must be adjacent to the subform that contains the button. If this isn't the case, you need to add additional levels of subform until you reach the adjacent subform.

For example:

Sub1
PositionInformation - PositionTitle
Sub2 - submit button

In this example, Sub1 and Sub2 are adjacent and 'PositionInformation' is within Sub1. For the button in Sub2 to be able to locate the 'PositionTitle' field it must be qualified as follows:

Sub1.PositionInformation.PositionTitle.rawValue.

You can test this in the button scripting window because it will always auto-suggest objects within a subform when it can find it correctly. So, on a new line type:

PositionInformation.

as you type the '.' it shoud auto-suggest - if it doesn't, it can't find the object because it isn't sufficiently qualified.

You also need to be very careful of case - all names are case-sensitive.

Hope this helps.
Runolfr
Registered: Oct 1 2008
Posts: 119
mike.ewins wrote:
Re your new puzzle - the syntax is identical, so it must be another problem. Does the structure of the 2nd form (in terms of subform hierarchy) differ from the first? My guess would be that you haven't qualified the field 'PositionTitle' enough. For the example above to work, the 'PositionInformation' subform must be adjacent to the subform that contains the button. If this isn't the case, you need to add additional levels of subform until you reach the adjacent subform.
That was one of the first things I checked, and apart from the subform names, the document heirarchies are essentially identical.

Form.Page(with button).Subform.Field

Even forgetting the proper path to the variable, the actual line of code doesn't seem to get called, because it doesn't apply the constant part of the subject line.

this.resolveNode("#event").submit.target = "mailto:ted [dot] collins [at] inspiris [dot] com?&subject=Position Fill Request, Title: "
+ PositionInformation.PositionTitle.rawValue;

I would have expected it to at least at ", Title: " to the subject line if the code were executing at all.
mike.ewins
Registered: Jun 23 2008
Posts: 4
Unfortunately, if there is a problem in the code it will stop all of the code executing. So you must try bits of the code separately to find out what is causing the problem.

Try removing the '+ PositionInformation.PositionTitle.rawValue' from the code and see whether the rest executes.

Likewise, you could remove all the code and just try:

app.alert(PositionInformation.PositionTitle.rawValue);

This will display a message box with the value of the field, if it is accessible.

You don't say whether the auto-suggest is finding the subform OK.

Let me know how you get on.
Runolfr
Registered: Oct 1 2008
Posts: 119
Auto-suggest was finding the path correctly. Turns out the problem seemd to be that the type of button had been changed a couple of times, and some bad code was stuck in the XML. We had to remove the button entirely and then replace it.
Ed Rooney
Registered: Sep 4 2009
Posts: 1
I am Using Life Cycle Designer ES8.3 to create a feedback form.

I am trying to get the Subject of an email to read "Feedback form for XX XX XX" where XX XX XX is the sub contractor that the user enters in to the form.

I have a textfield named SubContract and created a Button to utilise as the automated email.

I have gone through creating the button and ensured I have the mailto:myaddress [at] home [dot] com etc.Here is my current script... I have changed the email address for my security sake! Please could someone advise what code I can 'cut and paste' to select the data from the subcontract textfield that the user enters and then adds it on to the end of the subject line?

Any help gratefully received!

Ed