Knowledge base Feedback weekly notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2023 11:47 AM
Hi
I have a task to send a notification weekly, to the author of the Knowledge base article, with a overview of the articles that have received a comment. Can anyone please help me, on how I can achieve this?
Regards

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2023 12:28 PM
Hello @Mr-Pontus,
To send a notification weekly to the author of the Knowledge base article in ServiceNow, you will need to create a scheduled job that runs a script to query the articles that have received a comment in the past week and send an email to the author with the overview. You can use the GlideRecord API to access the database tables and the GlideSystem API to send emails.
Here is an example of a script that you can use or modify for your purpose:
// Define the start and end date of the past week
var startDate = new GlideDateTime();
startDate.addDays(-7);
var endDate = new GlideDateTime();
// Query the kb_knowledge table for articles that have received a comment in the past week
var gr = new GlideRecord('kb_knowledge');
gr.addQuery('sys_updated_on', '>=', startDate);
gr.addQuery('sys_updated_on', '<=', endDate);
gr.addQuery('comments', '!=', '');
gr.query();
// Loop through the articles and send an email to the author with the overview
while (gr.next()) {
// Get the author's email address
var author = gr.author.getRefRecord();
var email = author.email;
// Get the article's number, title, and comments
var number = gr.number;
var title = gr.short_description;
var comments = gr.comments;
// Construct the email subject and body
var subject = 'Weekly overview of your Knowledge base article: ' + number + ' - ' + title;
var body = 'Hello ' + author.name + ',\n\n';
body += 'Your Knowledge base article: ' + number + ' - ' + title + ' has received the following comments in the past week:\n\n';
body += comments + '\n\n';
body += 'Please review them and take appropriate actions if needed.\n\n';
body += 'Thank you for your contribution to the Knowledge base.\n\n';
body += 'Sincerely,\n';
body += 'Bing';
// Send the email using the GlideSystem API
var gs = new GlideSystem();
gs.sendEmail(email, '', subject, body);
}
Hope this helps.
Kind Regards,
Swarnadeep Nandy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2023 03:49 AM
Thanks, with some modifications I almost made it work, but unfortunately the gs.sendEmail function doesn't work

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 01:47 AM
Hello @Mr-Pontus,
instead of gs.sendEmail, what you can do it by triggering events from ServiceNow.
Or you can use the GlideEmailOutput API - https://developer.servicenow.com/dev.do#!/reference/api/vancouver/server/no-namespace/c_GlideEmailOu...
so you have to use it like
email.setBody(body);
Kind Regards,
Swarnadeep Nandy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 04:45 AM
Thank you @SwarnadeepNandy so I got it working, only problem now is that, there is sent an email for each comment that have been made. But I would like to create a "weekly summary" where the different authors get one email with all the articles that have received a comment, in one email
Kind regards
Pontus