In this post, I share Freemarker techniques & tips for both common and niche business uses cases requested by NetSuite clients.

I have gathered these techniques from the NetSuite community and developed several myself to meet client needs.


Advanced PDF/HTML Templates are a powerful tool for customizing the look and feel of your NetSuite PDFs. However, out-of-box, they are limited in functionality and require a combination of HTML/CSS, Freemarker, and BFO tags to create a fully customized and business-functional document.

The following tips are organized by business use case. For each, I will explain the business requirement or need, provide the Freemarker code and an explanation, give a working example, and explain any caveats.

I will continuously update this post. Please share your own tips/feedback in the comments or email me . I will enjoy hearing from you!

Display line numbers of items in a sublist:

 <!-- Items -->
        <#if record.item?has_content>
        <#assign linenum = 1> <!--Add line counter-->
            <table><!-- start items -->
                <#list record.item as item>
                    <#if item_index==0>
                        <thead>
                            <tr>
                                <th>...</th>
                            </tr>
                        </thead>
                    </#if>
                    <tr>
                        <td colspan="2">${linenum}</td> <!--Display line number-->
                    </tr>
                <#assign linenum = linenum + 1> <!--loop line counter-->
                </#list> <!-- end items -->
            </table>
        </#if>

Explanation:

  • Create a variable to count the line number
  • Display the line number
  • Increment the line number variable

Display sum of item quantity in a sublist:

 <#assign totalQuantity = 0>
    <#list record.item as item>
        <#assign totalQuantity = totalQuantity + item.quantity>
    </#list>
    <tr>
        <td colspan="11" align="right">Total Item Quantity:</td>
        <td colspan="1" align="right">${totalQuantity}</td>
    </tr>

Explanation:

  • Assign totalQuantity variable to 0
  • Create #list loop for the sublist
  • Create a loop that adds the quantity of each item to the totalQuantity variable
  • Display the totalQuantity variable

Contact Me

If you have any questions, please email me . If you just want to say Hello, find me on LinkedIn .