How to send one notification to same user for his multiple records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 10:39 AM
Hi Team,
If same inactive owner(testuser1) having multiple knowledge base records(Email,Knowledge,IT) in Knowledge base table, then we have to send only one notification to a particular DL (ABCD@servicenow.com) that owner is terminated for all these knowledge base records: Email,Knowledge,IT.
Could you please help me with the script if possible.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 10:48 AM
Hi Amrutha,
For this, I would create a report and schedule it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 10:59 AM
Hi Manoj,
Thank you for quick reply.
We have to implement in Scheduled Job.
Now I am using the below script, but if the same inactive owner having multiple kb records, then it is triggering multiple emails for the DL. In this case I want to send only one notification to DL.
var kbaseowner = new GlideRecord('kb_knowledge_base');
Could you please correct me if possible with the script.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 11:19 AM
Hi Amrutha,
Try something like this
var kbOwners = [];
var kbaseowner = new GlideRecord('kb_knowledge_base');
kbaseowner.addEncodedQuery('owner.active=false');
kbaseowner.query();
gs.log("javascript" + kbaseowner.getRowCount());
while (kbaseowner.next()) { // if the user is found
kbOwners.push(kbaseowner.owner);
}
var arrayUtil = new ArrayUtil();
var finalArray = arrayUtil.unique(kbOwners);
finalArray.forEach(createNotificationEvent);
function createNotificationEvent(ev){
gs.eventQueue("kb.kbmanagers.empty",ev);
}