Strange issue with a rich text field that is popul...
# advancedpdf
s
Strange issue with a rich text field that is populated via script: unless I make an edit to the field via the UI (i.e. simply remove a white space & SAVE), the Advanced PDF fails to render (without error). Any suggestions?
k
Why are you using a rich text field? I'm guessing you have some sort of formatting issue
s
So that I can inject html <br>. Just strange that something as simple as removing a period and then adding it back via UI, is sufficient to fix the issue.
m
I have the exact same issue. Reported a few lines above. Using rich text so users can put a formatted text into a (hopefully) printed doc. Ordered lists, bullets etc.
These are the errors I get when trying to render
Yes. An unhandled error was encountered: "{\"userEvent\":null,\"internalId\":null,\"code\":\"USER_ERROR\",\"details\":\"Error Parsing XML: Attribute \\\"href\\\" was already specified for element \\\"a\\\".\",\"stackTrace\":{\"[Ljava.lang.String;\":[\"createTripPDF(__pi_fs_print_trip_rpt.js$6068:58)\",\"<anonymous>(__pi_fs_print_trip_rpt.js$6068:73)\"]},\"type\":\"nlobjError\",\"suppressNotification\":false}" Patrick Olson  [1:38 PM] The error refers to line 58 of the Suitelet. "var pdfFile = nlapiXMLToPDF(xml);"
s
KevinJ was right about it being a formatting issue. after removing the '*&*' from the injected text, my problem disappeared.
k
Anything that could cause an auto escape is potentially likely to cause this sort of thing, ampersand, slash, quotations...
s
Thank you for your help.
m
Keep in mind if trying to use rich text fields in pdf templates - the NetSuite WYSIWYG editor will often change the html to non XML compliant tags. In BFO XML every tag needs to be closed (e.g.
<img />)
and NetSuite likes to remove the closing tag (
<img>
)
c
Can you force proper escaping with something like this?
Copy code
<#outputformat "HTML">${richTextField?esc}</#outputformat>
m
@Suite Deal I overcame this issue by implementing this solution from Marty Zigman that I found while Googling. It replaces the native rich text field with a new rich text editor using TinyMCE. This formats rich text using XHTML and works great with Advanced HTML/PDF https://blog.prolecto.com/2017/06/18/replace-netsuites-rich-text-editor-with-a-custom-html-editor/