Saurabh More
Saurabh More

Reputation: 413

Restrict values from printing in advanced pdf print

I want to restrict the value of item.rate from printing if it is given to '0.00' in the item table of the record

<#if item.rate?has_content && item.rate?string !='0.00'>
    <td style="vertical-align:bottom;" align="center" colspan="5"> ${item.rate}</td>
    <#else>
    <td style="vertical-align:bottom;" align="center" colspan="5"></td>
</#if>

I have tried this code.

Upvotes: 1

Views: 830

Answers (1)

michoel
michoel

Reputation: 3783

NetSuite is notoriously inconsistent with the field types it provides in Advanced PDF/HTML templates. I have a freemarker function called toNumber I use that makes sure I am dealing with numeric data.

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

Used as follows in your case:

<td style="vertical-align:bottom;" align="center" colspan="5">
    <#if toNumber(item.rate) != 0>${item.rate}</#if>
</td>

Upvotes: 1

Related Questions