Translated HTML fields show HTML code in email notifications

rosa8
Mega Contributor

For some reason when I include a field that is a Translated HTML field into an email notification, the HTML code prints and it looks like a mess. How do I get the data from the field to format properly? Regular HTML fields work fine.

I first noticed this when working on our kb_submission form. I'm trying to get the text to be included in the approval email notification. I'm also trying to include that same text in a notification to the Service Desk for Knowledge Articles are updated.

Thanks,
Rosa

17 REPLIES 17

I'm still waiting for a response from SN, but in the meantime I was able to make it work via a workaround.
I've created a business rule on sys_email as follows:

Table: sys_email
When: before
Insert: checked
Condition: current.target_table == "kb_knowledge" && !current.instance.nil() // or any other criteria that applies to your table
Script:
var kb = new GlideRecord("kb_knowledge");
kb.addQuery("sys_id", current.instance);
kb.query();

if (kb.next()) {
current.body += "


" + kb.text;
}

Basically I'm letting the email notification create the email and right before is inserted I'm adding to the body the HTML content.
This is working fine but I wish there's no need to do it this way.

/Amado Sierra


gaidem
ServiceNow Employee
ServiceNow Employee

In your notification do this(where current.description is your HTML field)
:



<mail_script>
template.print(JSUtil.unescapeText(current.description));
</mail_script>


NS16
Mega Sage

Hi @rosa8,

Did you find any solution on this issue?