Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Button for emailing

Avatar

Level 1

I have a fillable form and created a button that users can click on to send to a name that is entered in a text field named Manager.  In the script editor I have the following:

Subject.#subform[0].EmailManager::click - (JavaScript, client)

//Create a variable to hold the document object

var oDoc = event.target;

oDoc.mailDoc({

bUI: true,

cTo: Manager.formattedvalue,

cSubject: Location.formattedvalue + Department.formattedvalue + Subj.rawValue

});

(FYI..Location and department are dropdown boxes and subj. is a text box that already has preset value to it)

When I go to test the form, it doesn't email the name that's in the text field.  Does the cTo: have to be a raw.value? 

What am I missing?????? 

1 Reply

Avatar

Level 10

The formattedValue is a field's rawValue modified by a pattern. You'll use those generally on numeric or date fields but not in dropdown lists.

Use the rawValue instead like this way:

// Declare variables

var oDoc = event.target,

cTo = Manager.isNull ? "" : Manager.rawValue, // If field is empty return empty string instead of null

cSub = (Location.isNull ? "" : (Location.rawValue + " ")) + (Department.isNull ? "" : (Department.rawValue + " ")) + (Subj.isNull ? "" : Subj.rawValue);

// Send form

oDoc.mailDoc({

bUI: true,

cTo: cTo,

cSubject: cSub

});