1

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
RhysJ
  • 153
  • 1
  • 3
  • 19

2 Answers2

2

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}

bknights
  • 14,408
  • 2
  • 18
  • 31
  • Thanks a lot, bknights. That helps greatly. However, there is still a problem that I don't know why. The final report repeats the result FOUR times, which is the same as the original number of rows of data. I have updated my original problem. – RhysJ May 17 '17 at 21:06
  • Logically, that part of code should work. I didn't see where looping is triggered. – RhysJ May 17 '17 at 21:26
  • Do you have an outside <#list> like `<#list record.item as lineitem>` that you forgot to remove? – bknights May 17 '17 at 21:51
  • Also can you mark my answer to the other question as accepted? That's the title that'll tend to be more helpful – bknights May 17 '17 at 21:52
  • Yes, you are right. I did have an outside <#list> because of section. I just removed the <#list record.item as lineitem> one, and kept the outside <#list>, which works much better. However, it still repeated the outcomes twice in different order like: >>1. AA, 123, 22 >>2. AA, 123, 22 >>3. BB, 123, 36 >>4. BB, 123, 38 any idea? Thanks – RhysJ May 17 '17 at 22:41
  • forgot to mention that items should be sorted and grouped by storename, not cuscol_group_by. – RhysJ May 17 '17 at 22:59
0

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 -->
mustaccio
  • 18,234
  • 16
  • 48
  • 57
  • Please provide additional details in your answer. As it's currently written, it's hard to understand your solution. – Community Aug 31 '21 at 20:02