I need to specify default shipping method, for when none is provided on the entry form in Netsuite. For various reasons I have to do this within the PDF/HTML template. This is the code I have so far, but it doesn't seem to work;
<#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>
Your loop is going to print something each time it runs (i.e. 560 lines)! Instead of looping through the numbers, you should to test if the zip code falls within a desired range using the lte
(less than or equal to) and gte
(greater than or equal to) 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>