Search code examples
netsuitefreemarker

How to make an item always appear last on list (Netsuite Advanced PDF)


I am trying to make an item appear last on the list if it appears on an in the invoice (Advanced PDF,NetSuite).

I was thinking bout trying to sort by and adding some ZZZs to the item name, but thats because I dont really know much outside of basic HTML.

Any Help would be appreciated. Below is the table code I am dealing with.

 <table class="itemtable" style="width: 100%; margin-top: 10px;"><!-- start items --><#list record.item as item><#if item_index==0>
<thead>
    <tr>
    <th align="center" colspan="3">${item.quantity@label}</th>
    <th colspan="12">${item.item@label}</th>
    <th colspan="3">${item.options@label}</th>
    <th align="right" colspan="4">${item.rate@label}</th>
    <th align="right" colspan="4">${item.amount@label}</th>
    </tr>
</thead>
</#if><tr>
    <td align="center" colspan="3" line-height="150%">${item.quantity}</td>
    <td colspan="12"><span class="itemname">${item.item}</span><br />${item.description}</td>
    <td colspan="3">${item.options}</td>
    <td align="right" colspan="4">${item.rate}</td>
    <td align="right" colspan="4">${item.amount}</td>
    </tr>
    </#list>

I need the to be able to choose a specific itemname to always show at the bottom.


Solution

  • You can use the assign tag to hold the values for your bottom item.

    <#assign bottomItemName = 'Bottom Item Name'>
    <#assign bottomItem = {}>
    
    <#list record.item as item>
        <#if item_index==0>
            <thead>
                <tr>
                <th align="center" colspan="3">${item.quantity@label}</th>
                <th colspan="12">${item.item@label}</th>
                <th colspan="3">${item.options@label}</th>
                <th align="right" colspan="4">${item.rate@label}</th>
                <th align="right" colspan="4">${item.amount@label}</th>
                </tr>
            </thead>
        </#if>
        <#if item.item == bottomItemName>
            <#assign bottomItem = bottomItem + item>
        <#else>
            <tr>
                <td align="center" colspan="3" line-height="150%">${item.quantity}</td>
                <td colspan="12"><span class="itemname">${item.item}</span><br />${item.description}</td>
                <td colspan="3">${item.options}</td>
                <td align="right" colspan="4">${item.rate}</td>
                <td align="right" colspan="4">${item.amount}</td>
            </tr>
        </#if>
    </#list>
    
    <#if bottomItem.item??>
        <tr>
            <td align="center" colspan="3" line-height="150%">${bottomItem.quantity}</td>
            <td colspan="12"><span class="itemname">${bottomItem.item}</span><br />${bottomItem.description}</td>
            <td colspan="3">${bottomItem.options}</td>
            <td align="right" colspan="4">${bottomItem.rate}</td>
            <td align="right" colspan="4">${bottomItem.amount}</td>
        </tr>
    </#if>