Inserting Subtemplates into Templates
You can use the include
directive to insert another template inside of your template. This is often used when you have a template that presents information you want to reuse many times. For example, you might create a template that is used as a header for all communication you send out. This might include your company logo and contact information. The include
directive can reference template files by URL or File Cabinet ID.
For example, to insert a template in the NetSuite File Cabinet with the internal ID of 123, you could use:
<#include "123">
The number must be a file ID, not a template ID.
To insert a template by referencing the URL, you could use:
<#include "http://example.com/templates/myheader.ftl">
If you include templates from outside of NetSuite, your email may not be generated properly if there is a problem with the URL or the hosting website. Additionally, if the hosting website does not respond to the request for the template within five seconds, the email message is generated without that template. If the hosting website is an SSL site, it must have a trusted SSL certificate.
Templates that you insert with include
directives cannot themselves contain include
directives.
Custom Record Fields
You can reference fields on custom records using the same syntax used for standard fields and records:
{recordID.fieldID}
For example, if you wanted to reference a field with the internal ID customfield1 on a custom record with internal ID customrecord1, you could use:
{customrecord1.customfield1}
Including Images and Files
You can include images and files in scriptable templates.
There are three standard image fields you can add to scriptable templates:
-
Item Display Image (ID:
storeDisplayImage
) -item record -
Item Display Thumbnail (ID:
storeDisplayThumbnail
) -item record -
Image (ID:
image
) -entity records
References to these images are structured like this:
<img src="${contact.image}">
Including this code in a template creates a link to the image using the publishable URL on the image’s file record in the File Cabinet.
To include a link to a file in a scriptable template, reference the file record ID in an insert
directive. For example, the following code inserts the publishable file URL for file 123 in the email message:
<#include "123">
You can also include image and file custom fields in your templates.