Marty Zigman Marty Zigman
Prolecto Labs Accelerator Templates

Get a Handle on NetSuite PDF Templates: Handling The Ampersand (&) Symbol

NetSuite Technical

Tags: , ,

This article is relevant if you are working with NetSuite Advanced PDF Templates (and if you may be using the Content Renderer Engine (CRE)), and you are seeing issues with the ampersand (&) symbol.

Background

If you ever work with NetSuite’s native Advanced PDF template engine or CRE (Content Renderer Engine), and you see issues with using the ampersand (&) symbol in your code, then you are not alone. We were working on a particular project that required branding and logo work. We would get messages such as “The reference to entity “c” must end with the ‘;’ delimeter. That’s not easy to diagnose. Turns out that the ampersand (&) symbol requires some deliberate attention.

After a little bit of troubleshooting, it was discovered that the ampersand (&) symbol in the URL link to the custom logo image was not encoded properly for the CRE. Here’s how the initial link is provided by the NetSuite File Cabinet. Notice the ampersand (&) symbols in the URL. This is exactly what you would expect from a URL. However, this construct fails.

With a simple rework, we added some encoding to the ampersand (&) symbol as shown in the following code:

However, we discovered that this too caused issues in the CRE. With a little bit of ingenuity, one of our team experts came up with a clever approach to handling the ampersand (&) symbol in the CRE – specifically for handing those found in an image URL.

Handling The Ampersand (&) Symbol using Variables

In our case with the custom logo, the trick was to break apart the URL into subsections, assign these subsections to variables, and then lastly, encode the ampersand using &#38; instead of the common &amp; syntax. Here in our example, we are using FreeMarker to assign the URL values to a few variables. This code can be placed inside the <head> tag.

<head>
  <#assign img_logo1 = "https://system.na1.netsuite.com/core/media/media.nl?id=1580" />
  <#assign img_logo2 = "c=TSTDRV3657" />
  <#assign img_logo3 = "h=9d5402d8eea5abb" />
</head>

Then in the body of our template code, we can reconstruct our custom logo URL string and encode the ampersand using the alternate &#38; notation as shown.

<td colspan="2" rowspan="2" align="left">
  <img src="${img_logo1}&#38;${img_logo2}&#38;${img_logo3}" style="float: left; width: 173px; height: 49px; margin: 7px" />
</td>

Accelerate Your NetSuite PDF and HTML Development

If you are looking for ways to enrich your NetSuite Advanced PDF Templates, and you need something more than NetSuite’s out-of-the-box implementation, we offer the Content Renderer Engine (CRE) to help you accelerate your development giving you control, flexibility and more rapid development. Contact us to discuss your special NetSuite Advanced PDF / HTML generated application.

Marty Zigman

Holding all three official certifications, Marty is regarded as the top NetSuite expert and leads a team of senior professionals at Prolecto Resources, Inc. He is a former Deloitte & Touche CPA and has held CTO roles. For over 30 years, Marty has produced leadership in ERP, CRM and eCommerce business systems. Contact Marty to set up a conversation.

More Posts - Website - Twitter - Facebook - LinkedIn - YouTube

About Marty Zigman

Marty Zigman

Holding all three official certifications, Marty is regarded as the top NetSuite expert and leads a team of senior professionals at Prolecto Resources, Inc. He is a former Deloitte & Touche CPA and has held CTO roles. For over 30 years, Marty has produced leadership in ERP, CRM and eCommerce business systems. Contact Marty to set up a conversation.

Biography • Website • X (Twitter) • Facebook • LinkedIn • YouTube

13 thoughts on “Get a Handle on NetSuite PDF Templates: Handling The Ampersand (&) Symbol

  1. Corey says:

    Editor converted it. Using & amp; (without the space)

  2. Rick Cobb says:

    Marty,

    I have an advanced pdf/html template question. Do you know how the explosion of kit components is handled, and more specifically, whether that can be disabled on specific forms? We have a client that does NOT want components on quotes, orders, or invoices, but DOES want them on picking tickets and packing slips.

    The choices in NS don’t quite get me there; checking the Display Components on Transactions on the kit item explodes on all documents, while unchecking that box AND checking the Always Print Kit Items on Picking Tickets under Accounting Preferences | Order Management explodes the kit on picking tickets. There is no such choice for exploding on packing slips.

    If I can figure out how the explosion happens (or not) on a particular pdf template, then I can turn it on/off as needed for my client’s scenario. Or, perhaps we engage your firm to modify these forms for us (or devise an alternate solution)? Thanks for your help!

    Rick Cobb

  3. Eric Mushrush says:

    I just ran into this issue a few weeks back while creating a check template in the Advanced PDF/HTML Template UI. One thing I learned is that once you create your template using the Source Code View is to NOT go back to the nice GUI screen or you’ll loose a lot of what you modified in the source code view!

  4. Marty Zigman says:

    Hi Corey,

    Thank you. Yes, with Advanced PDFs no problem. I think we need to dig into the CRE tool. It may require special escaping to make this work the same as Advanced PDFs.

    Marty

  5. Marty Zigman says:

    Hi Rick,

    I would have to dig into what is offered out of the box. But now with CRE, I have found that my team and I worry much less. I finally have control over what is presented because I can pull in so much related NetSuite Saved Search data. It is easy, naturally, to hide data you don’t want to see. It’s (has been) much harder to get data!

    Marty

  6. Marty Zigman says:

    Hi Eric,

    Yes, I am so hard core into the template definition, I never go back to the GUI. So I probably missed this. Thanks for sharing.

    Marty

  7. Rick Cobb says:

    Marty,

    IN my case, we want to suppress data on a conditional basis. Let me explore your articles on your Content Rendering Engine and see how we might use such a tool. Thanks.

    Rick

  8. Nicolas says:

    Marty,

    How do you define the naming convention for pdf sent through email? Invoices, for instance, gets sent as Invoice_#invoicenumber_#additionalnumber. I don’t know what #additionalnumber is and how to remove it. Could you please enlighten me?
    Thanks!

  9. Marty Zigman says:

    Hi Nicolas,

    I don’t believe there is a way to change how NetSuite names the files by default. You have some choices:
    1) Program it yourself via SuiteScript or Workflows
    2) Leverage a tool like our Content Rendering Engine

    Marty

  10. Neethu says:

    Hi Marty,
    I need to apply conditional page break in Advanced PDF / HTML template. I have used for page break.. But it didn’t work. Could you please help me in this..

  11. Marty Zigman says:

    Hi Neethu,

    If you apply branching logic, you should be able to use page break syntax. See the pbr command at https://bfo.com/products/report/docs/tags/tags/pbr.html

    Marty

  12. Landor says:

    This is an old post, but still is a problem.

    I found a simpler solution and posted about it in this reddit post.

    Essentially our solution is to unescape the value and specify XML output format so it is properly escaped.

  13. Marty Zigman says:

    Hello Landor,

    That’s an interesting approach. Thanks for teaching us that.

    Marty

Leave a Reply

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