2017-03-01 42 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>