This article is relevant if you are producing software development work with NetSuite and you need to handle HTML encoding and decoding rules.
Background
Our Content Renderer Engine (CRE) has now been put to use in multiple complex client situations. Not only can we transform multiple linked saved searches into a NetSuite Advanced PDF template, we can transform the search result sets to feed data to Email Recipients, Subject, Message Body, and Document Names using template markup. We (and you, if you ask and have a real problem to solve) can now get to that hard to reach NetSuite data and then use it distribute and render meaningful content.
In our built-in CRE SuiteLet tester, we solve one of the other common challenges: the back and forth of development retrieving your data, and your template markup, and assessing the melding of the two. Yet, it is so easy to become accustom to think what you are seeing on screen is what you are actually working with. And thus we, the Prolecto team, were fooled and frustrated by NetSuite’s automatic handling of HTML braces encoding.
NetSuite Stores HTML Braces Encoded
The key to understand what is going on is that input forms in NetSuite are effectively HTML input element depending on the type. I created an experiment to ground my interpretations. I wrote a small JavaScript program to output the symbols for the common characters used in work we do. I then created three types of text input fields:
- Free Form Text
- Text Area
- Long Text
If you need to work with the strings in your application exactly as you expect (don’t we all), you can use some simple JavaScript to decode anything NetSuite automatically encoded:
input = String(input).replace(/</g, '<').replace(/>/g, '>');
NetSuite Ampersands Appear Spared
While I share this, the general HTML community knows that the three many characters to worry about are the “<“, “>” and “&”. Yet, NetSuite does not appear, from my testing, to take an ampersand (&) and turn it into “&” back at the database.
Work with NetSuite Experts
If you believe, as I do, that the NetSuite platform is just amazing in terms of how it can be used to solve business problems, and you want to be part of team that holds high standards for care and ethics while demonstrating your earned expertise and superior client leadership, perhaps we should have a conversation.
One thought on “Watch your Braces: NetSuite Handling Rules for HTML SuiteScript Developers”