Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Custom Email Subject from Form Fields - So Close

Avatar

Level 1

Hi folks.

I know I have to be close to figuring this out, but I need a smidge more help.  I've made a click event that submits my form, but when I try to add a custom subject from some fields in my form I get nothing.  Not even an error.  Please see the script and pinpoint what I'm doing wrong. 

Thanks so much!

Background:

-Precedence is a drop down list.

-CurrentDate is an automatically calculated text field.

-FullName is a user generated text field.

<event activity="click" name="event_click">
<script contentType="application/x-javascript">

var oDoc = event.target;
var to = "email@email.com";
var cc = "me@email.com";
var Precedence = this.getField("Precedence").value;
var CurrentDate = CurrentDate.rawValue;
var FullName = FullName.rawValue;
var subject = "New " + Precedence + " Request From " + FullName + " - " + CurrentDate;

oDoc.mailDoc({
bUI: true,
cTo: to,
cCC: cc,
cSubject: subject,
cMsg: "Please don't forget to add your products and all applicable sources before sending this email.  Thank you."
});
</script>

3 Replies

Avatar

Level 10

The getField method may be the problem, as this is not supported in XFA forms.

Use xfa.resolveNode("Precedence").rawValue instead.

Avatar

Level 1

Nope.  Changed the this.getField to xfa.resolveNode and still absolutely nothing.   

Avatar

Former Community Member

First of all it's weird to name your variables after your fields.

You will receive the field values by using rawValue as radzmar explained. If the pathing to the form field Precedence is correct, then this will work:

var Precedence = this.getField("Precedence").rawValue;

But since you are in a click even, the pathing will be totally wrong. The value "this" references to the field the user clicked on. Let's say you have the following hierarchy:

Subform A

     _ FieldName: Precendence

     _ Click Event Field

then the pathing would be

var Precedence = this.parent.getField("Precedence").rawValue;