Email Templates as XML Definitions
SuiteCloud Development Framework (SDF) supports email templates that generate personalized email messages to send to business contacts. The emailtemplate
SDF custom object can be used to develop custom email templates in a SuiteCloud project. You can create new email templates, or import existing email templates from a NetSuite account into a SuiteCloud project using SuiteCloud IDE plug-in or SuiteCloud CLI.
There are two components to email templates in a SuiteCloud:
-
The
emailtemplate
SDF custom object file, which contains the XML definition of the template record. -
The template definition file, which contains the HTML and FreeMarker code that defines the email template.
You can create email templates in an XML definition by creating both an email template SDF custom object and a template definition file.
The emailtemplate
SDF custom object file name must match the scriptID
attribute and requires the prefix custemailtmpl
, for example custemailtmpl_quoterequest.xml
. For information about the available fields for the emailtemplate
SDF custom object, see emailtemplate.
Consider the following information when working with template definition files:
-
The template definition file is automatically created when you create an
emailtemplate
SDF custom object file in SuiteCloud IDE plug-in. The template definition file is also included when you import anemailtemplate
SDF custom object into your SuiteCloud project. -
The template definition file can be stored in the objects folder or referenced in the File Cabinet. Only
emailtemplate
SDF custom objects in account customization projects are able to reference template definition files in the File Cabinet of the target account. SuiteApp projects must contain the template definition file in either the objects folder or the File Cabinet in the project. -
When the template definition file is not referenced in the File Cabinet:
-
The
usesmedia
field must be set to F in theemailtemplate
SDF custom object. -
The template definition file must be stored in the objects folder with the
emailtemplate
SDF custom object file. -
The template definition file name must be of the form
scriptID
.template.html, wherescriptID
is the script ID of theemailtemplate
object and also the object file name without the file extension. For example,custemailtmpl_quoterequest.template.html
is the template definition for the SDF custom objectcustemailtmpl_quoterequest.xml.
The file name provides the means for NetSuite to match the template definition with the template record when the objects are deployed to an account.
-
-
When the template definition file is referenced in the File Cabinet:
-
The
usesmedia
field must be set to T -
The
mediaitem
field of the SDF custom object must contain the path to the template definition file. -
For account customization projects, referenced files must be stored in the Templates/E-mail Templates or Templates/Marketing Templates directories of the File Cabinet in the SuiteCloud project or target account.
-
For SuiteApp projects, referenced files must be stored in the SuiteApps/
appID
directory in the SuiteCloud project, whereappID
is the application ID for the SuiteApp. -
Supported file types are HTML (.html), FreeMarker Template (.ftl), and Plain Text (.txt).
-
It can be beneficial to reference the template definition file when multiple
emailtemplate
objects can use the same template but require different attributes, or when the template definition is already stored in the target account.
-
For information about customizing the template definition, see the following:
Email Template XML Definition Examples
The following is an example of an emailtemplate
SDF custom object that defines an email template for messages confirming a quote request was received:
<emailtemplate scriptid="custemailtmpl_quoterequest">
<name>Reply to quote request</name>
<recordtype>ENTITY</recordtype>
<subject>We have received your request</subject>
<usesmedia>F</usesmedia>
</emailtemplate>
The emailtemplate
SDF custom object example has the file name custemailtmpl_quoterequest.xml
. The SDF custom object requires a template definition file with the file name custemailtmpl_quoterequest.template.html
, which contains the HTML and FreeMarker code that defines the email template. The content of custemailtmpl_quoterequest.template.html
is beyond the scope of this example.
For information about customizing email templates, see the following:
The following is an example of the same emailtemplate
SDF custom object referencing the template definition file quoterequest_template.html
in the File Cabinet.
<emailtemplate scriptid="custemailtmpl_quoterequest">
<name>Reply to quote request</name>
<recordtype>ENTITY</recordtype>
<subject>We have received your request</subject>
<usesmedia>T</usesmedia>
<mediaitem>[/Templates/E-mail Templates/quoterequest_template.html]</mediaitem>
</emailtemplate>