In version 2015.1, NetSuite has released the ability to merge Scriptable Email Templates in SuiteScript. This will require some significant coding changes from the only ‘nlapiMergeRecord’ function, which is being deprecated, and will no longer be supported as of Version 2016 Release 1.
To accomplish this, NetSuite has introduced a new ‘Email Merger’ object to merge your selected records with your Scriptable Email Template.
The old way…
var mergeResult = nlapiMergeRecord(’23’, ‘invoice’, nlapiGetRecordId(), ‘customer’, custId, ‘transaction’, tranId);
var emailSubject = mergeResult.getName();
var emailBody = mergeResult.getValue();
nlapiSendEmail(nlapiGetUser(), emailAddresses, emailSubject, emailBody);
The new way…
var emailMerger = nlapiCreateEmailMerger(’23’);
emailMerger.setEntity(‘customer’, custId);
emailMerger.setRecipient(‘customer’, custId);
emailMerger.setTransaction(tranId);
var mergeResult = emailMerger.merge();
var emailSubject = mergeResult.getSubject();
var emailBody = mergeResult.getBody();
nlapiSendEmail(nlapiGetUser(), emailAddresses, emailSubject, emailBody);
If your organization utilizes the template merge functionality and is looking to leverage the power of Scriptable Email Templates, Keystone is more than happy to advise you on updating your scripts.
Feel free to contact us directly thoughtleader@keystonebusinessservices.net.