can we send mail for duplicate knowledge article in servicenow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2024 10:39 AM
I Have a huge number of duplicate knowledge article, I want to send the work group owners an email notification so that they can check and remove the unnecessary one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2024 09:45 PM
Hi @SabyasachiM8774 ,
Assuming that you are finding the duplicates by same short description please find the below script which enables you to get all the sys_id's in an array.
var arr=[];
var agg = new GlideAggregate('kb_knowledge');
agg.addAggregate('COUNT', 'short_description');
agg.orderBy('short_description');
agg.addQuery('active', 'true');
agg.query();
while (agg.next()) {
var kbCount = parseInt(agg.getAggregate('COUNT', 'short_description'), 10);
// Display only if the count is greater than 1
if (kbCount > 1) {
gs.info('Short Description "{0}" has a count of {1}. KB Articles:', [agg.short_description, kbCount]);
// Query again to get the individual KB articles with this short_description
var kb = new GlideRecord('kb_knowledge');
kb.addQuery('short_description', agg.short_description);
kb.addQuery('active', 'true');
kb.query();
while (kb.next()) {
arr.push(kb.sys_id.toString());
gs.info('- KB Number: {0}, KB Sys ID: {1}', [kb.number, kb.sys_id]);
}
}
}
gs.print(arr);
You can call an event that triggers your email by sending the array values to the event as parameters.
Please mark my answer "Helpful" and "correct" if you feel that it has helped you in any way.
Thanks and Regards,
K. Sai Charan
Sr. ServiceNow Developer
Deloitte India
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2024 01:56 PM
Thank you for sharing the information that helps,
While I was extracting the report there were multiple duplicate articles for same work group. Please help how can I send emails to the work groups who are having duplicate articles. In the report I saw at least there are 100 and more work groups having duplicate article. Need to send mail separately each workgroup without sharing data.