render.mergeEmail(options)
Method Description |
Creates a render.EmailMergeResult object for a mail merge with an existing scriptable email template.
Note:
You must load the N/email Module to send and attach the email template to a record. |
Returns |
|
Supported Script Types |
Server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
None |
Module |
|
Since |
2015.2 |
Parameters
The options
parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
---|---|---|---|
|
number |
required |
Internal ID of the template. |
|
RecordRef |
optional |
The entity. |
|
RecordRef |
optional, the recipient can be specified with this parameter or with the email.send(options) method. |
The recipient. |
|
RecordRef |
optional |
The custom record. |
|
number |
optional |
The support case ID. |
|
number |
optional |
The transaction ID. |
RecordRef
You can use a RecordRef to designate the record to perform the mail merge on.
The RecordRef object encapsulates the type and ID of a particular record instance.
Property |
Type |
Required / Optional |
Description |
---|---|---|---|
|
number |
required |
Internal ID of the record instance. |
|
string |
required |
The record type ID. |
Syntax
The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/render Module Script Samples.
The following script sample uses the render.mergeEmail(options) method to attach a record and the email.send(options) method to send the email template to the recipient.
//Add additional code
...
/**
* @NApiVersion 2.x
*/
require(['N/email', 'N/render'], function(email, render) {
function sendEmail() {
var senderId = -5;
var recipientId = 1711;
var mergeResult = render.mergeEmail({
templateId: 7,
entity: {
type: 'employee',
id: senderId
},
recipient: {
type: 'customer',
id: recipientId
}
});
email.send({
author: senderId,
recipients: recipientId,
subject: mergeResult.subject,
body: mergeResult.body
});
}
sendEmail();
});
...
//Add additional code