How to add kb article in notification?

Servicenow10
Kilo Guru

hi 

i have 1 notification on incident table where i have to provide a link to kb article everytime this notification triggers.

so i wrote a email script and below is the code, but i only get the sys_id through it i want to print the content so how can i modify it to get results.

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {

// Add your code here

var link = new GlideRecord("kb_knowledge");
link.addQuery("number", "KB0010002");
link.addQuery("sys_id","add9a529dbd7b344123655784a96199e");

template.print("<b>Article is</b>: <a href='" + gs.getProperty('glide.servlet.uri') + "kb_view.do?sys_kb_id=" + link.sys_id + "'>" + link.number + "</a><br/>");

})(current, template, email, email_action, event);

 

am getting the link in my notification email script but when i click it gives record not found also it shows:

Article is : undefined

 

thanks

1 ACCEPTED SOLUTION

asifnoor
Kilo Patron

Hi,

you did not use link.query() and link.next() in your mail script because of which link.number is coming as undefined

Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.

Regards,
Asif
2020 ServiceNow Community MVP

View solution in original post

6 REPLIES 6

Bhagyashri Sort
Kilo Guru

Are you facing issue in opening link for escape character?

Just try this one.

escape charter

asifnoor
Kilo Patron

Hi,

you did not use link.query() and link.next() in your mail script because of which link.number is coming as undefined

Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.

Regards,
Asif
2020 ServiceNow Community MVP