Email KB Article
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2014 01:16 AM
Hi all,
I am looking for a way to email a link to a KB Article. I know there is already an "email" option within the OOB options, but we require the email to send from the users Outlook rather than from within ServiceNow.
I would prefer to have a "button" next to the "Edit Article" option, which opens the users default email client (Outlook), but I cannot find a way of adding this UI action? We require it to populate the Subject field with the KB Article Number and Title, and then populate the Body with a link to the article.
At present, I have simply edited the OOB code for the Email link found within Knowledge Base->Administration->Navigation Add-Ons to the following:
function emailArticle() {
var i = document.getElementById("sys_id");
if {
var id = i.value;
}
var text = "https://ourCompany.service-now.com/kb_view.do?sys_id=";
popupOpenEmailClient("mailto:?subject=KB Article&body=" + text + id);
}
This opens the mail client, and populates the subject and body. However, I need to get the "sysparm_article=KBNUMBER" instead of submitting the sys_id for the link to work. How can I find the "sysparm_article" attribute by using the sys_id attribute?
All help appreciated!
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2014 04:57 AM
Hi all,
I have managed to get this working, but there still remains a small issue. The following is the script I have developed:
function emailArticle() {
var i = document.getElementById("sys_id");
if ( i )
{
var id = i.value;
}
// Create GlideRecord on the KB table
var gr = new GlideRecord('kb_knowledge');
// Perform Query
gr.query();
if (gr.next())
{
if (gr.sys_id = id)
{
// Get KB Article Number
var num = gr.sys_id;
var name = gr.short_description;
// Open email client and populate subject and body
// Standard Link Text
var link = "https://company.service-now.com/kb_view.do?sys_kb_id=" + num;
var bodyText = "Please see article : ";
var subjectText = name;
popupOpenEmailClient("mailto:?Subject=KB Article&body="+ bodyText + link);
}
}
// End of Query Process
}
However, whilst the link works, the name variable is always the same?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2014 06:16 AM
Looks like you need to adjust your 'popupOpenEmailClient' line to look like this so that it contains your 'subjectText' variable.
popupOpenEmailClient("mailto:?Subject=KB Article: " + subjectText + "&body="+ bodyText + link);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2014 06:20 AM
Hi Mark,
I had actually changed that line since posting the initial question, but the problem still remains. It's bizarre how the article number changes (var num), and is correct, yet the name one is picking up the same KB article, regardless of which one I have selected.
The line is now :
popupOpenEmailClient("mailto:?Subject=KB Article :" + subjectText + "&body="+ bodyText + link);
Thanks,
Ryan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2014 06:25 AM
You're not passing in the ID of the article into your query so it's just picking up the first article in the table. Try this...
function emailArticle() {
var i = document.getElementById("sys_id");
if ( i )
{
var id = i.value;
}
// Create GlideRecord on the KB table
var num = '';
var name = '';
var link = '';
var bodyText = '';
var subjectText = '';
var gr = new GlideRecord('kb_knowledge');
gr.addQuery('sys_id', id);
// Perform Query
gr.query();
if (gr.next())
{
if (gr.sys_id = id)
{
// Get KB Article Number
num = gr.sys_id.toString();
name = gr.short_description.toString();
// Open email client and populate subject and body
// Standard Link Text
link = "https://company.service-now.com/kb_view.do?sys_kb_id=" + num;
bodyText = "Please see article : ";
subjectText = name;
popupOpenEmailClient("mailto:?Subject=KB Article - " + subjectText + "&body="+ bodyText + link);
}
}
// End of Query Process
}