- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2020 10:01 PM
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
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2020 04:11 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2020 10:21 PM
Hi,
Refer the following links
Email Notification - How to add link to KB Question or Article
Make it correct and helpful.
Thanks
Bhagyashri Sorte
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2020 10:26 PM
hi bhagyashree,
could you help me with this line as i am getting the error of unnecessary '\ escape character
template.print("<a href=\'" + instanceName + "nav_to.do?uri=kb_knowledge.do?sys_id=" + link.sys_id + "\'>" + link.number + "</a>");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2020 01:31 AM
Hi,
As you asked for the escape character issue. I think you are trying to use single quote and you won't close this before using double quote.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2020 03:43 AM