add KB article body text in "Notification: Article created "
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2020 09:33 AM
We want all users who subscribed to the knowledge base will get the email if new article is created.
This feature is OOB and working fine.
But when I try to add the article's body in the email, it is giving undefined.
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var obj = new JSON().decode(event.parm2);
var article_link = new KBCommon().getArticleLink(obj.sys_id);
email.setSubject("Reg: A new article "+obj.number+" has been created in "+obj.knowledge_base+" Knowledge Base.");
template.print("Hi "+obj.receiver+",<br/>");
template.print("<br/>");
template.print("An article has been created in the "+obj.knowledge_base+" Knowledge Base.<br/>");
template.print("<br/>");
template.print("<b>Article Number</b>: <a href='"+article_link+ "'>"+obj.number+"</a><br/>");
template.print("<b>Published Date</b>: "+obj.created_on+"<br/>");
template.print("<b>Body</b>: "+ obj.text+"<br/>");
})(current, template, email, email_action, event);
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2020 09:42 AM
Hi,
What table is the notification running on? Why are you not using current?
If the notification is running on the knowledge table you would be able to access it by using current.text
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2020 10:05 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2020 11:58 AM
I can see you already have the KB article sys_id so all you need to do is the following:
// Get the knowledge record from the data base
var knowledgeGr = new GlideRecord('kb_knowledge')
knowledgeGr.get(obj.sys_id);
template.print(knowledgeGr.getValue('text'))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 12:59 PM
Check out another post similar to yours that I replied to and was identified as the correct answer: