【问题标题】:My NetSuite Advanced PDF Template Couldn't Grouping Transaction Form Data我的 NetSuite 高级 PDF 模板无法对交易表单数据进行分组
【发布时间】:2017-10-17 09:14:02
【问题描述】:

目前,我的自定义交易表单中有一个值/属性表。我想编写一个高级 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

【问题讨论】:

标签: oracle freemarker netsuite


【解决方案1】:

groupby 不是 Netsuite 内置字段,也不是自定义交易列字段的形式。您需要使用内置字段或自定义列字段的脚本 ID 来完成这项工作,例如也许是“custcol_groupby”或“custcol5”或类似的东西。

您可以通过将 &xml=T 添加到您尝试打印的交易的查看 url 来获取该值,然后在结果页面上找到相应值的标记名。

${item.item} 中对 item 的引用也应引用 lineitem 或 groupItem,例如${lineitem.item}

【讨论】:

  • 非常感谢,bknights。这有很大帮助。但是,仍然存在一个我不知道为什么的问题。最终报告将结果重复 4 次,与原始数据行数相同。我已经更新了我原来的问题。
  • 从逻辑上讲,这部分代码应该可以工作。我没有看到循环在哪里触发。
  • 您是否有忘记删除的外部 ,例如 <#list record.item as lineitem>
  • 您还可以将我对另一个问题的回答标记为已接受吗?这个标题会更有帮助
  • 是的,你是对的。由于 部分,我确实有一个外部 。我刚刚删除了 之一,并保留了外部 ,这样效果更好。但是,它仍然以不同的顺序重复了两次结果,例如:>>1。 AA, 123, 22 >>2。 AA, 123, 22 >>3。 BB, 123, 36 >>4。 BB, 123, 38 知道吗?谢谢
【解决方案2】:

是的。您可以使用排序或直接对记录进行分组。在我的情况下,要求是如果项目名称相同,则添加数量并仅在单行上打印相同的项目名称

    <#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 -->

【讨论】:

  • 请在您的回答中提供更多详细信息。正如目前所写的那样,很难理解您的解决方案。
猜你喜欢
  • 2014-05-08
  • 2020-07-18
  • 2020-05-20
  • 2020-01-25
  • 2018-01-10
  • 2018-10-20
  • 2022-12-04
  • 1970-01-01
  • 2017-02-19
相关资源
最近更新 更多