Jelly - Displaying Translated HTML field in its formatted HTML on UI Page

kristenankeny
Tera Guru

Everything I'm finding says that <g2:no_escape> should work to display a kb article's text field (a translated HTML field) in its formatted form (so This is bold instead of <b>This is bold</b>), but it's not working for me. This is the snippet of the jelly:

<div style="padding-left:40px">
<b><h3><div style="color:#6f6f6f">$[kbArt.u_outline_order] $[kbArt.short_description]</div></h3></b>
<div style="padding-left:10px"><g2:no_escape>$[kbArt.text]</g2:no_escape></div>
</div>

This is however, resulting in the html code being displayed instead. Where am I going wrong?

1 ACCEPTED SOLUTION

kristenankeny
Tera Guru

I was able to resolve the issue by changing all j2 and g2 tags to j and g. I'm not positive why this worked, but it did and that's all I care about.

View solution in original post

6 REPLIES 6

LaurentChicoine
Tera Guru

The OOB UI Macro displaying knowledge article uses <g2:no_escape>$[NS:knowledgeRecord.text]</g2:no_escape>.

Thanks for the suggestion. I had checked an OOB UI page, but not the UI macros. Unfortunately this is also a no go - still getting the html code and not the formatted text.

Thats weird, does your OOB kb_view page works correctly?

Here is a simple UI Page I tried in an OOB instance to try it out:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
	<g2:evaluate>
		var kbArt = new GlideRecord('kb_knowledge');
		kbArt.get('24d9243187032100deddb882a2e3ec33');
	</g2:evaluate>
<div style="padding-left:40px">
<b><h3><div style="color:#6f6f6f">$[kbArt.short_description]</div></h3></b>
<div style="padding-left:10px"><g2:no_escape>$[kbArt.text]</g2:no_escape></div>
</div>
</j:jelly>

It renders as HTML content without any issue, maybe this is related to a system property you switched (however I could not find anything related to that).

Could you check to make sure your text is not stored as escaped HTML. With the example knowledge article I provided, you would go in "Scripts - Background" menu and run the following:

var kbArt = new GlideRecord('kb_knowledge');
kbArt.get('24d9243187032100deddb882a2e3ec33');
gs.print(kbArt.text);

Then check the output to see if it is printed like <b>bold</b> or like &lt;b&gt;bold&lt;/b&gt;

It's giving me <b>Bold</b>