Urjent!!!! html tags are displayed in the notification preview

Tejaswini9
Tera Expert

Hello,

I am facing an issue in email preview, the html tags are displayed in email notification when the content type is "html/plain text" as well

find_real_file.png

and this is the code i have written in "Message Text" 

<b><font color='Red'>*Note - Please do not reply to this email. Click on the approved or deny icon below to choose the appropriate action. Once selected an email will be generated. Select send to complete the process.</font></b>

<b>Requested Item Number:</b> ${sysapproval}
<b>Item Requested:</b> ${sysapproval.short_description}
<b>Request date:</b> ${sysapproval.sys_created_on}
<mail_script>
template.print("Summary of Requested items:\n");
var item = new GlideRecord("sc_req_item");
item.addQuery("sys_id", current.sysapproval);
item.query();
while(item.next())
{
var keys = new Array();
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(item.sys_id);
set.load();
var vs = set.getFlatQuestions();
for (var i=0; i < vs.size(); i++) {
if(vs.get(i).getLabel() != '') {
template.space(4);
template.print(' ' + vs.get(i).getLabel() + " : " + vs.get(i).getDisplayValue() + "\n");
}
}
}
</mail_script>
</mail_script>
</mail_script>
<hr/>

${mailto:mailto.approval}
<hr/>
${mailto:mailto.rejection}
<hr/>
<b>Click here to view Approval Request:</b> ${URI}

Regards,

I really dont know what is the error and can anyone help me with this please, This is bit urjent for me.

Many thanks in advance.

1 ACCEPTED SOLUTION

you have to use message html.

you don't need to use the html tags ,it creates them automatically.

You can use the source code in the html editor and paste your html code.

 

Difference between Message text and message html.

 

 

Message HTML

Enter the content of the email notification message. The message can include variables from the Select variables column.

Variables map to column names available from the notification table, its parent tables, and reference tables. Use variables to include values from a record in the table such as an incident short description or comments and work notes.

The Message HTML field is visible only if you set the content type to HTML and plain text or HTML only.

If empty, the system uses the Message HTML value from the Email template. If you enter a value in this field, it overrides the template value.

To prevent adding extra <p> and <div> elements to your email notifications, see the blog post Extra line spacing with paragraph tags in email client by a ServiceNow employee in the ServiceNow Now Community.

Message Text

Enter the notification message to send in plain text. This field is visible only if you set the content type to HTML and plain text or Plain text only.

If empty, the system uses the Message Text value from the Email template. If you enter a value in this field it overrides the template value.

View solution in original post

9 REPLIES 9

Pranav Bhagat
Kilo Sage

You have to change the type to  Message HTML.

Content type should be HTML .

Refer this :https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/administer/notification/task/t_CreateANotification.html

 

Regards

Pranav

The content type is set to "HTML and Plain text" and i have only 2 options 1.HTML and Plain text 2. Plain text only. in my instance

You have to use HTML.

Ashley Snyder1
Giga Guru

Also it looks like your mail script is inline, using inline mail scripts was deprecated. Per the documentation: 

If you manually enter a mail script bounded by <mail_script> and </mail_script> in the body of a new or converted email notification or template, and then attempt to save the record, a message asks whether the mail script should be converted. In many cases, an unconverted mail script fails to run from inside the HTML editor. If you select Yes, the script is added to the Email Script [sys_script_email] table and is automatically replaced in the body with an embedded script tag (${mail_script:script_name}).

https://docs.servicenow.com/bundle/paris-servicenow-platform/page/script/server-scripting/concept/c_...

So more than likely your unconverted mail script is failing to run inside the HTML editor as the documentation states.