如何让指定商品在NetSuite Advanced PDF发票列表中始终排在末尾
解决方案
你之前提到的给商品名加ZZZ前缀的方案虽然可以临时实现效果,但会改变商品正常显示内容,且依赖名称排序规则稳定性较差,更规范的方案是利用NetSuite Advanced PDF底层使用的FreeMarker模板语法,将商品列表拆分后分别渲染,无需修改商品本身的任何属性。
完整修改后代码
<table class="itemtable" style="width: 100%; margin-top: 10px;"> <!-- 自定义逻辑开始:拆分普通商品和需固定到底部的商品 --> <#assign targetBottomItemName = "这里替换为你要沉底的商品实际名称"> <#assign normalItems = []> <#assign bottomItems = []> <#list record.item as item> <#if item.item == targetBottomItemName> <#assign bottomItems = bottomItems + [item]> <#else> <#assign normalItems = normalItems + [item]> </#if> </#list> <!-- 自定义逻辑结束 --> <!-- 渲染普通商品 --> <#list normalItems as item> <#if item_index==0> <thead> <tr> <th align="center" colspan="3">${item.quantity@label}</th> <th colspan="12">${item.item@label}</th> <th colspan="3">${item.options@label}</th> <th align="right" colspan="4">${item.rate@label}</th> <th align="right" colspan="4">${item.amount@label}</th> </tr> </thead> </#if> <tr> <td align="center" colspan="3" line-height="150%">${item.quantity}</td> <td colspan="12"><span class="itemname">${item.item}</span><br />${item.description}</td> <td colspan="3">${item.options}</td> <td align="right" colspan="4">${item.rate}</td> <td align="right" colspan="4">${item.amount}</td> </tr> </#list> <!-- 最后渲染需固定到底部的商品 --> <#list bottomItems as item> <tr> <td align="center" colspan="3" line-height="150%">${item.quantity}</td> <td colspan="12"><span class="itemname">${item.item}</span><br />${item.description}</td> <td colspan="3">${item.options}</td> <td align="right" colspan="4">${item.rate}</td> <td align="right" colspan="4">${item.amount}</td> </tr> </#list> </table>
可选配置调整
- 若需要多个商品固定到底部,把判断条件改为:
<#if ["商品名1","商品名2"]?seq_contains(item.item)>即可 - 为了避免商品重名导致匹配错误,建议使用商品内部ID判断,将判断条件改为
<#if item.itemid == "目标商品ID">即可
内容的提问来源于stack exchange,提问作者iNEEDhelp
相关产品推荐
相关产品推荐

