0

I have a custom field with some HTML code in it:

<h1>A H1 Heading</h1>
<h2>A H2 Heading</h2>
<b>Rich Text</b><br>
fsdfafsdaf df fsda f asdfa f asdfsa fa sfd<br>
<ol><li>numbered list</li><li>fgdsfsd f sa</li></ol>Another List<br>
<ul><li>bulleted</li></ul>

I also have another non-stored field where I want to display the plain text version of the above using REGEXP_REPLACE, while preserving the carriage returns/line breaks, maybe even converting <br> and <br/> to \r\n

However the patterns etc... seem to be different in NetSuite fields compared to using ?replace(...) in freemarker... and I'm terrible with remembering regexp patterns :)

Assuming the html text is stored in custitem_htmltext what expression could i use as the default value of the NetSuite Text Area custom field to display the html code above as:

A H1 Heading

A H2 Heading

Rich Text

fsdfafsdaf df fsda f asdfa f asdfsa fa sfd

etc...

I understand the bulleted or numbered lists will look crap.

My current non-working formula is:

REGEXP_REPLACE({custitem_htmltext},'<[^<>]*>','')

I've also tried:

REGEXP_REPLACE({custitem_htmltext},'<[^>]+>','') - didn't work

Steve Reeder
  • 980
  • 16
  • 42

2 Answers2

0

When you use a Text Area type of custom field and input HTML, NetSuite seems to change the control characters ('<' and '>') to HTML entities ('<' and '>'). You can see this if you input the HTML and then change the field type to Long Text.

If you change both fields to Long Text, and re-input the data and formula, the REGEXP_REPLACE() should work as expected.

Krypton
  • 4,394
  • 2
  • 9
  • 13
  • One of the source fields is the webstore description {storedescription}. I'm not sure which type that field is. – Steve Reeder Mar 20 '19 at 22:34
  • That's a Rich Text field, which has similar wrinkles. Are you entering the HTML in Formatted Edit Mode or Source Edit Mode? – Krypton Mar 21 '19 at 03:29
0

From what I have learned recently, Netsuite encodes data by default to URL format, so from < to &lt; and > to &gt;.

Try using triple handlebars e.g. {{{custitem_htmltext}}}

https://docs.celigo.com/hc/en-us/articles/360038856752-Handlebars-syntax

This should stop the default behaviour and allow you to use in a formula/saved search.