Add KB Article link in notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-15-2020 11:40 PM
Hi All,
I want to fetch the Kb article number from incident ,So there is a filed on incident form as u_knowledge which saves trhe kb article number. i want to give the link of that particular KB article in portal view from the notification.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-15-2020 11:50 PM
Hi Priya,
You can do below.
1. Create mail script - getkblink
2. Code as below.
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
var kbis=current.u_knowledge;
var getarticle = new GlideRecord('kb_knowledge');
getarticle.addQuery('sys_id',kbis);
getarticle.query();
while (getarticle.next()) {
var urlis = '/sp?id=kb_article&sys_id=' + getarticle.sys_id + 'table=kb_knowledge';
template.print('<a href="' + urlis + '">' + gs.getMessage(getarticle.number) + '</a>');
}
})(current, template, email, email_action, event);
3. Call the mail script in Incident notifications body in format ${mail_script:getkblink}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-15-2020 11:52 PM
Hello Priya
you need a email script for this. Assuming notification is on incident table, create a mail script and call in the notification
${mail_script:get_kbarticle_link}
Mail script: get_kbarticle_link
script
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var attachLink = '<a href="' + gs.generateURL('kb_knowledge',current.u_knowledge) + '">' + current.u_knowledge.getDisplayValue()+ '</a>';
template.print(attachLink + "<br />");
})(current, template, email, email_action, event);
Mark the comment as a correct answer and also helpful once worked.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-16-2020 03:24 AM
Hello Priya,
Did you check the code that i have given. If want the link to open in a portal, just use the below code and it will work.
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var attachLink = '<a href="' + gs.getProperty('glide.servlet.uri')+'/sp?id=kb_article&sys_id='+current.u_knowledge + '">' + current.u_knowledge.getDisplayValue()+ '</a>';
template.print(attachLink + "<br />");
})(current, template, email, email_action, event);
Mark the comment as a correct answer and also helpful once worked.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-16-2020 03:41 AM
Hello Priya,
kindly mark the comment as a correct answer if this code has worked for you.