Search code examples
pdfnetsuitefreemarkersuitescriptsuitescript2.0

How to group and sort items in netsuite advanced pdf template?


In netsuite advanced pdf template to print sales order pdf,

I am getting output for club type and club sub type as:

Club Type Club Sub type
Iron 5 Iron
Putter 6 Putter
Wood Wood 5
Wedge Wedge 2
Iron 9 Iron
Wood Wood 1
Wedge Wedge 5

Now, I want to group club type and sort club sub type within each club type group in ascending order like,

Iron – 5 Iron, 9 Iron
Putter – 6 Putter
Wedge – Wedge 2, Wedge 5
Wood – Wood 1, Wood 5

Please help! Thanks in advance.

Below is advanced pdf template item table:

<table style="width: 100%; margin-top: 10px;">
<!-- start items -->
<#list record.item as item><#if item_index==0>
<thead>
    <tr>
    <th>Qty</th>
    <th>ITEM</th>
    <th>CLUB<br/>TYPE</th>
    <th>CLUB<br/>SUB<br/>TYPE</th>
    <th>HEAD</th>
    <th>SHAFT</th>
    <th>GRIP</th>
    </tr>
</thead>
    </#if><tr>
  <td>${record.item.quantity}</td>
  <td>${item.item}</td>
  <td>${item.custcol_cc_clubtype_so}</td>
  <td>${item.custcol_cc_club_subtype_so}</td>
  <td>${item.custcol_cc_head_description_so}</td>
  <td>${item.custcol_cc_shaft_description_so}</td>
  <td>${item.custcol_cc_grip_description_so}</td>
    </tr>
</#list><!-- end items --></table>

Solution

  • I have combined club type and club sub type and stored it in a custom line level field on sales order record. Fetched values from that field in a advanced pdf and sorted this field. and its giving expected output.