我的 NetSuite 高级 PDF 模板无法对交易表单数据进行分组
My NetSuite Advanced PDF Template Couldn't Grouping Transaction Form Data
目前,我的自定义交易表格中有 table 个 values/attributes。我想编写一个高级 PDF 模板,所以当我将表单打印为 PDF 时,一些值被分组到不同的部分。
例如,我的表单有四个属性,分别称为 Store Name、Product ID 和 NumOfSales,如下所示。
1. AA, 123, 10
2. AA, 123, 12
3. BB, 123, 29
4. BB, 124, 9
我想写一个高级的pdf模板,打印出来的效果如下图。
1. AA, 123, 22
2. BB, 123, 38
groupby不是Netsuite内置字段,也不是自定义交易列字段形式。您需要使用内置字段或自定义列字段的脚本 ID 来完成这项工作,例如也许 'custcol_groupby' 或 'custcol5' 或类似的东西。
您可以通过将 &xml=T 添加到您尝试打印的事务的视图 url 来获取该值,然后在结果页面上找到适当值的标记名。
${item.item}
中对项目的引用也应引用 lineitem 或 groupItem,例如${lineitem.item}
是的。您可以使用排序或直接对记录进行分组。在我的例子中,要求是如果项目名称相同,则添加数量并在单行上打印相同的项目名称
<#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 -->
目前,我的自定义交易表格中有 table 个 values/attributes。我想编写一个高级 PDF 模板,所以当我将表单打印为 PDF 时,一些值被分组到不同的部分。
例如,我的表单有四个属性,分别称为 Store Name、Product ID 和 NumOfSales,如下所示。
1. AA, 123, 10
2. AA, 123, 12
3. BB, 123, 29
4. BB, 124, 9
我想写一个高级的pdf模板,打印出来的效果如下图。
1. AA, 123, 22
2. BB, 123, 38
groupby不是Netsuite内置字段,也不是自定义交易列字段形式。您需要使用内置字段或自定义列字段的脚本 ID 来完成这项工作,例如也许 'custcol_groupby' 或 'custcol5' 或类似的东西。
您可以通过将 &xml=T 添加到您尝试打印的事务的视图 url 来获取该值,然后在结果页面上找到适当值的标记名。
${item.item}
中对项目的引用也应引用 lineitem 或 groupItem,例如${lineitem.item}
是的。您可以使用排序或直接对记录进行分组。在我的例子中,要求是如果项目名称相同,则添加数量并在单行上打印相同的项目名称
<#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 -->