2017-03-01 39 views
0

我需要指定默认的发货方式,因为Netsuite的输入表单上没有提供。由于各种原因,我必须在PDF/HTML模板中执行此操作。 这是我到目前为止的代码,但它似乎没有工作;如果在Netsuite PDF/HTML模板上使用数字范围的陈述

<#function toNumber val> 
<#if val?has_content && val?length gt 0 > 
<#return val?html?replace('[^0-9.]','','r')?number > 
<#else><#return 0 ></#if></#function> 

<#if record.shipmethod?has_content> 

${record.shipmethod} <!-- if a courier is selected --> 

<#else>    <!-- else --> 
<#list 2000..2560 as pcx> <!-- Sydney Metro postcodes --> 
<#if toNumber(record.shipzip)==pcx> 

Courier1    <!-- Standard Sydney Metro Courier --> 

<#else>    <!-- else --> 

Courier2    <!-- Standard Interstate Courier --> 

</#if></#list></#if> 

回答

0

您的循环每次运行时都会打印一些东西(即560行)!而不是通过数字循环的,则应该以测试是否邮政编码使用lte(小于或等于)和gte(大于或等于)comparison operators期望的范围内:

<#function toNumber val> 
<#if val?has_content && val?length gt 0 > 
<#return val?html?replace('[^0-9.]','','r')?number > 
<#else><#return 0 ></#if></#function> 

<#assign zip = toNumber(record.shipzip)> 

<#if record.shipmethod?has_content> 
    ${record.shipmethod} 
<#elseif zip gte 2000 && zip lte 2560 > 
    Courier 1 
<#else> 
    Courier 2 
</#if>