如何将一个变量分配为其他变量的差?

时间:2019-01-08 07:30:05

标签: netsuite freemarker

我们正在NetSuite中使用FreeMarker。

现在,我们需要一个变量作为其他变量的差。 我的想法如下:

<#assign paymentValue = apply.total- apply.due>

但是系统说:

Tip: If the failing expression is known to be legally refer to something 
that's sometimes null or missing, either specify a default value like 
myOptionalVar!myDefault, or use <#if myOptionalVar??>when- 
present<#else>when-missing</#if>. (These only cover the last step of the 
expression; to cover the whole expression, use parenthesis: 
(myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??

然后我尝试了这个:

<#if apply.total??>${apply.total}<#else>0</#if>
<#if apply.due??>${apply.due}<#else>0</#if>
<#assign paymentValue = apply.total-apply.due>

但是结果是一样的。

如何将一个变量分配为其他变量的差异?

1 个答案:

答案 0 :(得分:1)

最后,我找到了解决方案。

错误是在“ <#list record.apply as apply>”中声明了“ apply”,但是我在其之前使用了apply.total。

现在我声明如下,它对我有用:

<#list record.apply as apply>
<#assign paymentValue = apply.total - apply.due>

感谢您的贡献。

相关问题