ANS-0384 · SUITESCRIPT DEVELOPMENT
How to Strip HTML Tags from NetSuite’s storedetaileddescription Field
Learn how to remove HTML markup from the storedetaileddescription field to extract plain text for reporting or display purposes.
Short answer
To convert the storedetaileddescription field to a textual value, use a regular expression to strip HTML tags. This method targets raw HTML elements. Be aware that if the content is HTML-encoded (e.g., < for '<'), an additional decoding step may be required before applying the regex for complete tag removal.
Scenario
Users often need to extract plain text from fields that store rich HTML content, such as the storedetaileddescription field. This is typically required for display in areas that do not render HTML, for data exports, or for simplified reporting where only the textual content is relevant.
Solution
To convert the storedetaileddescription field into a textual value by removing HTML tags, the following regular expression can be applied. This approach is effective for stripping raw HTML elements from the field's content.
fieldValue fieldValue.replace(/<(?:.|
)*?>/gm, '');It is important to note that if the storedetaileddescription field contains HTML-encoded characters (e.g., < for ''), this regular expression will not correctly strip the HTML tags without a prior decoding step. NetSuite may HTML-encode content in certain field types, which would require additional processing to fully convert the content to plain text.
Expert NetSuite Support
Need help with this NetSuite issue?
SuiteScript Development consulting and configuration support
