ANS-1037 · PRINTING, PDF & EMAIL TEMPLATES
How to Insert Record Fields into Email Templates Using SuiteScript
When standard NetSuite email template merging is insufficient, SuiteScript offers a solution to dynamically insert record fields into emails.
Short answer
To dynamically insert record fields into an email template via SuiteScript, use `nlapiCreateTemplateRenderer` (or `render.create()` in SuiteScript 2.x). This function enables programmatic merging of data into scriptable templates, providing a robust solution when standard template merging is insufficient for custom email content.
Scenario
Users often encounter situations where standard NetSuite email template functionality does not allow for the direct insertion of specific fields from a record into an email. This limitation becomes apparent when attempting to send emails programmatically via SuiteScript, requiring dynamic data merging beyond basic template capabilities. The challenge is to ensure that custom or complex record data is accurately reflected in outgoing email communications.
Solution
When standard email template merging is insufficient, an alternate solution involves using SuiteScript to programmatically render templates.
While SuiteScript 1.0 functions like nlapiCreateTemplateRenderer and nlobjTemplateRenderer are still supported, the current development standard is SuiteScript 2.x, which provides equivalent functionality through the N/render Module (e.g., render.create() and render.TemplateRenderer).
This approach allows for dynamic merging of record data into scriptable templates.
For a sample script demonstrating this alternate solution, consult NetSuite's documentation or community resources for examples on sending emails that reference scriptable templates using template rendering objects.
Expert NetSuite Support
Need help with this NetSuite issue?
Printing, PDF & Email Templates consulting and configuration support
