The New Way to Merge Scriptable Email Templates in SuiteScript

The New Way to Merge Scriptable Email Templates in SuiteScript

The New Way to Merge Scriptable Email Templates in SuiteScript

By on May 14, 2015

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.

 

Kevin is responsible for driving the cloud-based technology vision for Keystone and its customers. In his role as Keystone’s lead technical expert, Kevin is deeply involved in most NetSuite and Salesforce.com implementation projects. Kevin’s expertise includes systems planning and analysis, custom application development, and cloud computing platform administration via Amazon Web Services. Prior to Keystone, Kevin held a variety of technical and functional roles throughout a diverse set of industries such as financial services, manufacturing, and advertising. Kevin holds an MBA from the Keller Graduate School of Management and a BS in Commerce from DePaul University.