Reputation: 173
Currently, I have a table of values/attributes in my Custom Transaction Form. I want to write an Advanced PDF Template, so when I print the form as PDF, some values are grouped to different sections.
For example, my form has four attributes, called Store Name, Product ID, and NumOfSales, like the following.
1. AA, 123, 10
2. AA, 123, 12
3. BB, 123, 29
4. BB, 124, 9
I want to write an advanced pdf template so that the printed result looks like the following.
1. AA, 123, 22
2. BB, 123, 38
Upvotes: 1
Views: 2260
Reputation: 1
Yes. Either you can use sort or directly by grouping the record. In my case requirement was if items name are same add the quantity and print same item name on single Line Only
<#if record.item?has_content>
<table class="itemtable" style="width: 100%; margin-top: 10px;"><!-- start items -->
//Declare Array
<#assign item_name = []>
//Used Sorting by Item
<#list record.item?sort_by('item') as item><#if item_index==0>
<thead>
<tr>
<th colspan="12" style="height: 2px;" border="1px solid #A9A9A9" color="white" background-color="#A9A9A9">${item.item@label?replace('NetSuite','')}</th>
<th align="center" colspan="3" style="height: 2px;" border="1px solid #A9A9A9" color="white" background-color="#A9A9A9">${item.quantity@label}</th>
<th align="right" colspan="4" style="height: 2px;" border="1px solid #A9A9A9" color="white" background-color="#A9A9A9">${item.rate@label?replace('Rate','Tax Rate')}</th>
</tr>
</thead>
//Here main logic -first Group
</#if>
<#assign group = item.item>
<#assign lineid = item.line>
<#assign qty = item.quantity>
//second Group for comparision
<#list record.item as item2>
<#assign group1 = item2.item>
<#assign lineqty = item2.quantity>
<#assign lineid2 = item2.line>
//group comaprision and if lindid not same
<#if group==group1 && lineid != lineid2>
//sum of quantity
<#assign qty = qty+item2.quantity>
</#if>
</#list>
//if not contains same item then processed further
<#if !( item_name?seq_contains(item.item))>
<tr>
<#assign item_name = item_name + [item.item]>
<td colspan="12" style="height: 40px;"><span class="itemname">${item.custcol_so_displayname}</span><br />${item.description}</td>
<td align="center" colspan="3" line-height="150%" style="height: 40px;">${qty}</td>
<td align="right" colspan="4" style="height: 40px;">${item.taxrate1}</td>
</tr>
</#if>
</#list><!-- end items --></table>
<hr /></#if>
<!-- end snippet -->
Upvotes: 0
Reputation: 15462
groupby is not a Netsuite built-in field nor is it in the form of a custom transaction column field. You'll need to use the script id of a built in field or custom column field to make this work e.g. maybe 'custcol_groupby' or 'custcol5' or something like that.
You can get the value by adding &xml=T to the view url of the transaction you are trying to print and then find the tagname for the appropriate value on the resulting page.
Also references to item as in ${item.item}
should refer to lineitem or groupItem e.g. ${lineitem.item}
Upvotes: 2