how to write a script to link knowledge base article in notification without using sys id in snow?

Nandhini Sri
Tera Contributor
 
1 ACCEPTED SOLUTION

try this:

(function runMailScript(current, template, email, email_action, event) {
var tpsa = new GlideRecord("kb_knowledge");
tpsa.addQuery("number", "KB0017341");
tpsa.query();
if(tpsa.next())
{
var instance = gs.getProperty('glide.servlet.uri');
var text = "kb_view.do?sys_kb_id="+tpsa.sys_id;
var newURL = '<a href="' + instance+text+ '"> click here </a>';
template.print(newURL);
}

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

 

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

View solution in original post

3 REPLIES 3

sushantmalsure
Mega Sage
Mega Sage

can you describe more about your requirement?

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

Nandhini Sri
Tera Contributor
(function runMailScript(current, template, email, email_action, event) {
var tpsa = new GlideRecord("kb_knowledge");
tpsa.addQuery("number""KB0017341");
tpsa.addQuery("sys_id","c07f3860879831d8dbbc63583cbb3557");
tpsa.query();
if(tpsa.next())
{
var instance = gs.getProperty('glide.servlet.uri');
var text = "kb_view.do?sys_kb_id=c07f3860879831d8dbbc63583cbb3557";
var newURL = '<a href="' + instance+text+ '"> click here </a>';
template.print(newURL);
}

})(current, template, email, email_action, event);
 
my requirement to replace sysid in  tpsa.addQuery("sys_id","c07f3860879831d8dbbc63583cbb3557"); and 
var text = "kb_view.do?sys_kb_id=c07f3860879831d8dbbc63583cbb3557";
to include this particular kb article in notification body. how to replace it any suggestions?

try this:

(function runMailScript(current, template, email, email_action, event) {
var tpsa = new GlideRecord("kb_knowledge");
tpsa.addQuery("number", "KB0017341");
tpsa.query();
if(tpsa.next())
{
var instance = gs.getProperty('glide.servlet.uri');
var text = "kb_view.do?sys_kb_id="+tpsa.sys_id;
var newURL = '<a href="' + instance+text+ '"> click here </a>';
template.print(newURL);
}

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

 

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure