Convert Amount to Number in advanced PDF template

An error is displayed as “Can’t convert this string to number” when attempting to generate the PDF. This error arises because the number retrieved from the record might be interpreted as a string, which prevents the successful generation of the print. To address this issue, please refer to the sample code provided below for a solution.

<#assign gross =0>
 <#if record.onsaveshipmentweight?has_content>
 <#if record.onsaveshipmentweight?contains(",")>
      <#assign gross = record.onsaveshipmentweight?replace(",","")?number>
 <#else>
      <#assign gross = record.onsaveshipmentweight?number>
 </#if>
</#if>
${gross?string(",##0.00")}

Leave a comment

Your email address will not be published. Required fields are marked *