You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否在NetSuite高级PDF模板中无需脚本检查Item子类型?

NetSuite高级PDF模板数量字段条件显示方案

可以不用脚本,直接通过NetSuite高级PDF使用的Freemarker模板语法,调用Item的内置字段完成条件判断。NetSuite的Item记录在模板中可直接访问itemtype(主类型)和subtype(子类型)字段,完全满足你“仅非库存Item且子类型为Sale时显示数量”的需求。

核心判断逻辑

针对每行Item,判断两个条件:

  • 主类型为Non Inventory Item(非库存商品)
  • 子类型为Sale

需要分别处理表头和表体的数量元素,避免表格结构错位:

  1. 表头:仅当存在符合条件的Item时显示数量列标题(或逐行判断,但统一表头更美观)
  2. 表体:每行根据Item类型决定是否渲染数量值,不符合条件时显示空单元格维持结构

修改后的完整代码

<#if record.item?has_content>
<table class="itemtable" style="width: 100%; margin-top: 10px; margin-left: -5px;"> 
<!-- start items -->
<#list record.item as item>
<#if item_index==0>
<thead>
    <tr style="border-bottom:1px;">
        <th colspan="12">${item.description@label}</th>
        <th align="center" colspan="4">Number Of Users</th>
        <!-- 条件渲染数量列表头 -->
        <#if item.itemtype == "Non Inventory Item" && item.subtype == "Sale">
        <th colspan="2">${item.quantity@label}</th>
        </#if>
        <th align="right" colspan="4">Unit Price</th>
        <th align="right" colspan="4">${item.amount@label}</th>
    </tr>
</thead>
</#if>
<tr>
    <td colspan="12"><span class="itemname">${item.item}</span><br />${item.description}</td>
    <td colspan="4">${item.quantity}</td>
    <!-- 条件渲染表体数量单元格 -->
    <#if item.itemtype == "Non Inventory Item" && item.subtype == "Sale">
    <td align="center" colspan="2" style="line-height: 150%;">${item.quantity}</td>
    <#else>
    <!-- 不符合条件时显示空单元格,保持表格对齐 -->
    <td align="center" colspan="2" style="line-height: 150%;">&nbsp;</td>
    </#if>
    <td align="right" colspan="4">${item.rate}</td>
    <td align="right" colspan="4">${item.amount}</td>
</tr>
</#list>
<!-- end items -->
</table>
</#if>

注意事项

  • 字段值需与NetSuite系统内显示完全一致:若使用自定义语言包,需替换为对应语言的类型名称;
  • 若需更严谨的判断,可使用Item类型的内部ID(如非库存商品主类型内部ID为NonInvtPart),但显示值更直观;
  • 空单元格的处理是为了避免表格列错位,保证布局整齐。

内容的提问来源于stack exchange,提问作者Maira S

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 15:17:04