Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

in javascript can we use html

Vedavalli
Kilo Sage

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

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@Vedavalli 

please share where have you written this?

share screenshots

💡 If my response helped, please mark it as correct ✔️ and close the thread 🔒 — this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

script used in notification in link to content tab

(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 = gs.getMessage("This requested item needs your review.");

 

    var variablesDetails = "";

    var variables = gr.variables.getElements();

    for (var i = 0; i < variables.length; i++) {

        var question = variables[i].getQuestion();

        variablesDetails += "**" + question.getLabel() + "**:   " + question.getDisplayValue() + "\n\n";

    }

 

    messageContent += "\n\n" + variablesDetails;

 

    return {

        messageHeading: messageHeading.join(" - "),

        messageContent: messageContent

    };

 

})(target, event, recipientTable, recipientSysId, vaNotificationRuntimeContext);

this script returns variable and answers i want to show them in a tabular format

 

@Vedavalli 

screenshots please, where have you written this script

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader