Freemarker advanced pdf/html NetSuite Reporting

Use FreeMarker Functions in your Reporter Layouts and Advanced PDF/HTML Templates in NetSuite

Did you know that you can build you own FreeMarker functions when working with SuiteCorner’s Reporter app or with NetSuite Advanced PDF/HTML Templates in NetSuite?

If your layouts for example contain logic including calculations and/or color-coding based on criteria, using functions can make your code more condensed and easier to navigate in.

The function should include a name, necessary parameter(s) and a return value. You can also store values inside your function using local. Below are some examples of functions and how they can be referenced.

When using functions in your code make sure to always define the function before calling the function. Best practice is therefore to define your codes early in the code or, if you are using Reporter, add them under the dedicated Functions subtab in the Layout editor.

Adding two values:

<#function addValues param1 param2>
   <#local result = (param1 + param2) />
   <#return result />

Calling function:

${addValues ( var1?number, var2?number ) }

Calculating average value of two number:

<#function calculateAverage param1 param2>
   <#local result = ((param1 + param2)  / 2) />
   <#return result />

Calling function:

${calculateAverage ( var1?number, var2?number ) }

Color number based on thresholds (upper and lower)

<#function colorThreshold value upper lower>
   <#if value gte upper>
      <#local result = “green” />
  <#elseif value lt lower >
      <#local result = “red” />
      <#local result = “yellow” />
   <#return result />

Calling function:

<span color=”${colorThreshold( var1?number, 10?number, 5?number)}”>${var1}</span>

Here is an example from our prebuilt Reporter for Sales – Sales Rep report where we use a FreeMarker function to color and highlight the current trend for the sales rep’s key customers.

Reporter for NetSuite Freemarker funktion advance pdf

Learn more >>




See more blog posts