Considerations: Migrating NetSuite CRMSDK Templates to Scriptable Freemarker

This article is relevant if you are seeking to migrate your legacy NetSuite email and merge templates to the new scriptable format.


NetSuite had announced in 2015 that it is deprecating the use of the CRMSDK tags in place of the scriptable tags under the Freemarker template engine.   However, the real impact of this is felt during the 2016.2 release.  The CRMSDK tags will not render right and thus, you are forced to convert to get your content to look right.

Since most of the client work we do is for more complex matters, we haven’t really had to deal with simple template conversions. ¬†As many people know, we are experts with Freemarker and have developed a very powerful “Content Rendering Engine (CRE)” available to our clients to supercharge their NetSuite template production. ¬† Due the changes in 2016.2 release, we expect the NetSuite community is going to encounter a few issues. ¬† This article is meant to highlight some basic items that may come up.

Resolving Issues with Saving NetSuite Scriptable Templates

One issue we experienced with a converted template was with Freemarker’s built-in mechanism to round numbers. ¬†Since we were working with Bitcoin for our Bitcoin Transaction Coordinator, we need to have eight decimals of precision. ¬†Our basic CRMSDK email templates had no problem outputting the eight decimals. ¬†However, Freemarker wanted to round to four decimals without us asking our permission. ¬†To solve this, you use the Freemarker “built-in” modifier to express a number in “computer” fashion by simply qualifying the template variable with a “?c” suffix. ¬†However, when you do this, NetSuite may not allow you to save the template.

In this case, we ended up getting an error such as:

The template cannot be saved due to the following errors:
customRecord.CUSTRECORD_BTC_TRX_QUANTITY_GROSS is not a number, it is com.netledger.templates.model.EmptyModel

To solve these types of challenges, which have to do with NetSuite’s datatype assumptions as ¬†they pre-parse the Freemarker template upon save, use a variable and test for a null situation. ¬†See the following template syntax which can be placed at the top of your template.¬†¬†When you want to reference the variable, do so this way:

<#assign amt=0>
<#if customRecord.CUSTRECORD_BTC_TRX_QUANTITY_GROSS?has_content>
   <#assign amt=customRecord.CUSTRECORD_BTC_TRX_QUANTITY_GROSS>

Reference the value this way:


instead of this direct way:


Migrate Scripts to nlapiCreateEmailMerger

If you were previously using nlapiMergeRecord to produce merged templates, you will need to modify your code to use the new nlapiCreateEmailMerger function. Fortunately, the code is pretty easy. Here is a before and after.

mailMerge = nlapiMergeRecord(template, 'customrecord_btc_trx_request',;
nlapiSendEmail(emailFrom, emailName, mailMerge.getName(), mailMerge.getValue(), null, null, records, attachment);


mailMerge = nlapiCreateEmailMerger(template);
mailMergeResult = mailMerge.merge();
nlapiSendEmail(emailFrom, emailName, mailMergeResult.getSubject(), mailMergeResult.getBody(), null, null, records, attachment);

Get Expert NetSuite Help

If you are like me, you think the NetSuite platform really is space for innovation. If you want to work with professionals that can optimize your day-to-day NetSuite use while opening up new opportunities to generate revenue and lower costs, let’s have a conversation.

Be Sociable, Share!

Marty Zigman

Holding all three official certifications, Marty is Southern California's NetSuite expert and leads a team of senior professionals at Prolecto Resources, Inc. He is a former Deloitte & Touche CPA and has held CTO roles. For over 25 years, Marty has produced leadership in ERP, CRM and eCommerce business systems. Contact Marty to set up a conversation.

More Posts - Website - Twitter - Facebook - LinkedIn - Google Plus - YouTube

| Tags: , , , , | Category: Infrastructure, Reporting, Technical | 2 Comments


  1. kumar
    Posted March 7, 2017 at 3:52 am | Permalink

    Hi Sir,
    I sourced a multi select custom field with customers with sourcing & filtering in customer record, These multi select field values (customers) are visible at record edit modde only, they are not visible at view mode, please help me sir, to show the values in view mode.

  2. Posted March 18, 2017 at 6:14 am | Permalink

    Hi Kumar,

    Unfortunately, you can’t get the values of the underlying multi-select fields in this mode. However, you can, via script, load the field array and the iterate it to learn the values.


Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>