【发布时间】:2020-01-25 21:29:55
【问题描述】:
我正在尝试采用当前电子邮件模板,我的组织使用该模板根据客户当前的待处理交易请求订单存款,因此 freemarker 可以很好地获取 ${transaction.tranId} 等。
我有一个新要求,即获取交易行级超链接并将其与电子邮件请求一起发送,但我只想在该数据存在且仅针对链接适用的项目时发送它。
<#if (record.item.custcol1)?has_content>
<p><strong>Please re-review the following artwork proof link(s) associated with your order:</strong></p>
<table style="width: 100%; margin-top: 10px;"><!-- start items --><#list record.item as item>
<thead>
<tr>
<th align="left" colspan="3" style="padding: 10px 6px;">${item.custcol1@label}</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" colspan="3" line-height="150%">${item.custcol1}</td>
</tr>
</#list><!-- end items -->
</tbody>
</table>
<hr style="width: 100%; color: #d3d3d3; background-color: #d3d3d3; height: 1px;" /></#if>
我似乎无法像在 PDF 表单中那样访问行级数据。我已经在已知记录上尝试了没有 if 语句的代码,我知道我有数据可以访问,但它不会将字段提取到电子邮件中。
【问题讨论】:
-
如果我没看错并理解您的要求,您应该在
<#if>中包含<#if>块 - 您想要测试每个项目的字段内容,而不是整个项目列表作为一个块。此外,record.item.custcol1将无效 - 您需要为要测试的项目提供索引,例如:record.item[0].custcol1如果这是您的意图。
标签: netsuite freemarker