Search code examples
templatesnetsuitebfo

Adding page breaks to tables in PDF templates for NETSuite


On page 176/177 of the SuiteBuilder Customisation Guide, Oracle explain how it's possible to add page breaks to tables within a template.

The example given is:

<!-- start of item table in transaction -->
<#list record.item as item>
    <#if item_index==0> <!-- Header Definition -->
        <tr>
            <th>${item.field1@label}</th>
            <th>${item.long_text_field@label}</th>
            <th>${item.field2@label}</th>
            <!-- ... -->
        </tr>
    </#if>
    <#list item.long_text_field?split("<br />") as paragraph>
        <#if desc_index==0>
            <tr>
                <td>${item.field1}</td>
                <td>${paragraph}</td>
                <td>${item.field2}</td>
                <!-- ... -->
            </tr>
        <#else>
            <tr>
                <td></td>
                <td>${paragraph}</td>
                <td></td>
                <!-- ... -->
            </tr>
        </#if>
    </#list>
</#list>
<!-- end of item table in transaction -->

However this is resulting in the following error:

enter image description here

It appears that the term desc_index is unable to be evaluated, and furthermore, the term does not appear an any other NETSuite related documentation other than here.

Is this a bug/typo/deprecated code?


Solution

  • This is a typo in the example.

    List indexes in Freemarker are referenced by concatenating the list name with "_index". So, in this example, desc_index should be replaced with paragraph_index.

    It appears they adapted this example from another snippet with a list name of 'desc' (probably for 'description') but neglected to update the index reference to match.

    Of course, you need to change long_text_field, field1 and field2 to real fields that are available to the template for it to work.