in javascript can we use html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2025 10:48 PM
In notifications I've configured for team actionable notification. SO IN LINKN TO CONTENT I'VE written javascript to show the variables i wanted to show in tabular format. So how to use html in that script . i used table,tr,td tags not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2025 11:35 PM
I don't think HTML tags work there.
For testing you can try adding a message which is with bold tag <b>
If it works then table tag should also work
if not then HTML tags are not supported there.
💡 If my response helped, please mark it as correct ✔️ and close the thread 🔒 — this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2025 10:57 PM
Follow below documentation link
You can also refer below articles
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0727884
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0743622
If this helped to answer your query, please mark it helpful & accept the solution.
Thanks,
Bhuvan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2025 11:46 PM
Hi @Vedavalli ,
in your script Right now, you are joining the text using ** and \n.
These symbols work only for plain text not for HTML.
can you pls try this script :
(function getNotificationHeadingAndMessage(
target,
event,
recipientTable,
recipientSysId,
vaNotificationRuntimeContext
) {
var approval_record = new GlideRecord("sysapproval_approver");
approval_record.get(target.sys_id);
var requested_item_record = approval_record.sysapproval.getRefRecord();
var ritm_sysid = requested_item_record.sys_id;
var ritm_number = requested_item_record.number;
var gr = new GlideRecord("sc_req_item");
gr.get(ritm_sysid);
var item = gr.cat_item.name;
var messageHeading = [ritm_number, item];
var messageContent = "<p>This requested item needs your review.</p>";
// Start HTML table
var variablesDetails = "<table style='border-collapse:collapse; width:100%;' border='1' cellpadding='5'>";
variablesDetails += "<tr><th>Question</th><th>Answer</th></tr>";
var variables = gr.variables.getElements();
for (var i = 0; i < variables.length; i++) {
var question = variables[i].getQuestion();
variablesDetails +=
"<tr><td>" +
question.getLabel() +
"</td><td>" +
question.getDisplayValue() +
"</td></tr>";
}
// Close the table
variablesDetails += "</table>";
messageContent += variablesDetails;
return {
messageHeading: messageHeading.join(" - "),
messageContent: messageContent
};
})(target, event, recipientTable, recipientSysId, vaNotificationRuntimeContext);
