Activity Tab showing emails sent unrelated to that record

IkchhitP
Tera Contributor

I have my issue record under policy & compliance. I opened a record and found that it's showing sent emails unrelated to that record. And there are many such emails in the activity stream of that record. I checked on the sys_email table business rules and also issues table business rule but couldn't find anything which would have triggered this action.Pasted image.png

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

@IkchhitP 

did you check in emails table if those emails triggered for that same record or other one?

it should show only if the emails sent/received on current record

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron

@IkchhitP 

did you check in emails table if those emails triggered for that same record or other one?

it should show only if the emails sent/received on current record

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I can't check it on the other instance as I do not have access to it. However, these notifications are triggered via event. And I am triggering those events using a scheduled job.
Scheduled Job code:

var targetDate = new GlideDateTime();
targetDate.addDaysUTC(60);
var targetDateOnly = targetDate.getDate();
var att = new GlideRecord('sn_grc_issue');
att.addEncodedQuery('stateIN1,2,5^assigned_toISNOTEMPTY^classification!=4^due_dateONToday@javascript:gs.dateGenerate("' + targetDateOnly + '","00:00:00")@javascript:gs.dateGenerate("' + targetDateOnly + '","23:59:59")');
att.query();
if (att.next()) {
    var attA = new GlideAggregate('sn_grc_issue');
attA.addEncodedQuery('stateIN1,2,5^assigned_toISNOTEMPTY^classification!=4^due_dateONToday@javascript:gs.dateGenerate("' + targetDateOnly + '","00:00:00")@javascript:gs.dateGenerate("' + targetDateOnly + '","23:59:59")');
    attA.addAggregate('COUNT');
    attA.groupBy('assigned_to');
    attA.query();
    var list = '';
    while (attA.next()) {
        gs.eventQueue('sn_grc.issue_due_in_60days', att, attA.assigned_to, attA.assigned_to.manager);
    }
}


In the scheduled job it checks the records which are due after 60 days. And I am aggregating them by the 'assigned_to' so that the person receives only 1 notification