Does Oracle NetSuite Advanced PDF Template have “Group by” and “SUM” Functions?

℡╲_俬逩灬. 提交于 2020-01-07 04:00:23

问题


duplicated question, sorry......


回答1:


If you can do the processing/grouping prior to passing data to freemarker you are better off. However if you are doing something like extending the standard transaction forms that isn't a simple option.

You can simulate grouping by using sequence operations. (see http://freemarker.org/docs/ref_builtins_sequence.html)

Then:

<#assign seen_style = []>
<#list record.item?sort_by('custcol_style') as lineitem>
    <#assign lineStyle = lineitem.custcol_style>
    <#if seen_style?seq_contains(lineStyle)>
    <#else>
        <#assign seen_style = seen_style + [lineStyle]>
        <#assign styleTotal = 0>
        <#list record.item?sort_by('custcol_size') as styleItem>
           <#if lineStyle == styleItem.custcol_style>
              <#assign styleTotal = styleTotal + styleItem.quantity>
          </if>
        </#list>
       <div>${lineStyle} has ${styleTotal}</div>
   </#if>
</#list>



回答2:


The full Freemarker documentation is available here.

There are no built-in functions such as group_by() or sum(), and though you could put something together using <#list> directives etc., you would have a much easier time doing this in JavaScript using a library like lodash.

For more information in how to combined SuiteScript and Advanced PDF/HTML Templates, see the help section topic Using SuiteScript to Apply Advanced Templates to Non-Transaction Records, or if you are using SS2.0 see the N/render module.



来源:https://stackoverflow.com/questions/44013395/does-oracle-netsuite-advanced-pdf-template-have-group-by-and-sum-functions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!