Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The NetSuite Pro

The NetSuite Pro Logo The NetSuite Pro Logo

The NetSuite Pro Navigation

  • Home
  • About Us
  • Tutorials
    • NetSuite Scripting
    • Advanced PDF Templates in NetSuite
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask A Question
  • Home
  • About Us
  • Tutorials
    • NetSuite Scripting
    • Advanced PDF Templates in NetSuite
  • Blog
  • Contact Us
Home/ Advanced PDF Templates in NetSuite/Basic FreeMarker Syntax in NetSuite Advanced PDF

Basic FreeMarker Syntax in NetSuite Advanced PDF

NetSuite Advanced PDF/HTML templates use FreeMarker, a Java-based template engine, to insert dynamic data into your PDF layouts. FreeMarker allows you to:

  • Print field values (e.g., customer name, invoice total).
  • Loop through line items.
  • Apply conditions (e.g., show a field only if not empty).
  • Format dates, numbers, and currencies.

Below are the most common FreeMarker syntax elements allowed in NetSuite with practical examples.


🔹 Printing Fields

Use ${} to display field values.

<p>Invoice Number: ${record.tranid}</p>
<p>Customer: ${record.entity}</p>
<p>Total Amount: ${record.total}</p>
  • record = transaction object (Invoice, Sales Order, PO, etc.).
  • ${record.fieldId} = inserts the value of that field.

🔹 Conditional Statements

Use <#if> and <#else> for logic.

<#if record.custbody_discount?has_content>
   <p>Discount Applied: ${record.custbody_discount}</p>
<#else>
   <p>No discount available.</p>
</#if>

✔️ ?has_content checks if the field has a value.
✔️ You can compare values too:

<#if record.status == "Paid">
   <p><b>Thank you for your payment!</b></p>
</#if>

🔹 Looping Through Line Items

Use <#list> to iterate over sublists like item.

<table border="1" width="100%">
   <tr>
      <th>Item</th>
      <th>Quantity</th>
      <th>Rate</th>
      <th>Amount</th>
   </tr>
   <#list record.item as i>
      <tr>
         <td>${i.item}</td>
         <td>${i.quantity}</td>
         <td>${i.rate}</td>
         <td>${i.amount}</td>
      </tr>
   </#list>
</table>

✔️ record.item = item sublist.
✔️ ${i.fieldId} = field inside the sublist.


🔹 Formatting Dates & Numbers

NetSuite supports FreeMarker built-ins for formatting.

<p>Transaction Date: ${record.trandate?string("MMMM dd, yyyy")}</p>
<p>Total Amount: ${record.total?string["#,##0.00"]}</p>
  • ?string("MMMM dd, yyyy") → formats dates as “September 26, 2025”.
  • ?string["#,##0.00"] → formats numbers with commas and 2 decimals.

🔹 Escaping Null Values

If a field is empty, you can default it with !.

<p>Sales Rep: ${record.salesrep!"Not Assigned"}</p>

✔️ If salesrep is empty, it shows “Not Assigned”.


🔹 Useful FreeMarker Operators in NetSuite

SyntaxUsage ExampleResult
${field}${record.entity}Prints customer
<#if><#if record.total > 1000>Conditional
<#list><#list record.item as i>Loop through lines
?has_content${field?has_content}Checks if field has value
!${field!"N/A"}Default value
?string()${date?string("yyyy-MM-dd")}Format date/number
Share
  • Facebook

Leave a ReplyCancel reply

Sidebar

Ask A Question

Stats

  • Questions 6
  • Answers 6
  • Best Answers 0
  • Users 2
  • Popular
  • Answers
  • Rocky

    Issue in running a client script in NetSuite SuiteScript 2.0 ...

    • 1 Answer
  • admin

    How can I send an email with an attachment in ...

    • 1 Answer
  • admin

    How do I avoid SSS_USAGE_LIMIT_EXCEEDED in a Map/Reduce script?

    • 1 Answer
  • admin
    admin added an answer The issue is usually caused by following Wrong script file… September 14, 2025 at 10:33 pm
  • admin
    admin added an answer Steps to send an Invoice PDF by email: define(['N/email', 'N/render',… August 28, 2025 at 3:05 am
  • admin
    admin added an answer This error means your script hit NetSuite’s governance usage limit… August 28, 2025 at 3:02 am

Top Members

Rocky

Rocky

  • 1 Question
  • 21 Points
Begginer
admin

admin

  • 5 Questions
  • 2 Points

Trending Tags

clientscript netsuite scripting suitescript

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

© 2025 The NetSuite Pro. All Rights Reserved