Search code examples
freemarkernetsuitesuitetalk

NetSuite Advanced PDF/HTML - Displaying images with URL from custom field


I am trying to create an Advanced PDF/HTML template that will display an image using a URL that is in a custom field. The custom field is a hyperlink and the field ID is {custitem_dp_image1}. I am using the image tag and referencing the {custitem_dp_image1} field as the src but I am unable to save the template due to the following error:

java.lang.StringIndexOutOfBoundsException: String index out of range: 0 java.lang.InternalError: java.lang.StringIndexOutOfBoundsException: String index out of range: 0

I've also tried the following code:

<#if result.custitem_dp_image1?length != 0><img src="${result.custitem_dp_image1}" style="width: 100px; height: 100px;" /> </#if>

But I received the following error when I tried to view the Advanced PDF/HTML template from a Saved Search:

The template cannot be saved due to the following errors: org.xml.sax.SAXParseException; lineNumber: 53; columnNumber: 28; The value of attribute "src" associated with an element type "img" must not contain the '<' character.

*The template was stored as invalid.

How can I get this to work and display the image?


Solution

  • The solution is to change the custom field to type = Free-Form Text and use the following freemarker code:

    <#if result.custitem_dp_image1?length != 0><img src="${result.custitem_dp_image1}" style="width: 100px; height: 100px;" /> </#if>