We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Exclude users from receiving notifications

ShubhankarK9612
Tera Contributor

Hi Community,

 

I want to exclude 9 users from receiving notifications and these notifications gets triggered by a schedule Jobs which runs daily. Can I use conditional script in the scheduled Job or do I need to write an email script. 

11 REPLIES 11

Ankur Bawiskar
Tera Patron

@ShubhankarK9612 

yes in your scheduled job script where you are grabbing the recipients based on your logic, simply add script to exclude those 9 users.

💡 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  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur, Thanks for the reply.

 

Can you please help me with the script to achieve this?

@ShubhankarK9612 

you didn't share the scheduled job script so can't help

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

@Ankur Bawiskar Here is the script:

 

var gdtNow = new GlideDateTime();
var gdtStart = new GlideDateTime();
var gdtEnd = new GlideDateTime();
 
gdtStart.addDaysLocalTime(-6);
gdtStart.setDisplayValue(gdtStart.getLocalDate().getDisplayValue() + " 00:00:00");
 
 
gdtEnd.addDaysLocalTime(-6);
gdtEnd.setDisplayValue(gdtEnd.getLocalDate().getDisplayValue() + " 23:59:59");
 
 
var gr1 = new GlideRecord('incident'); {
   // gr1.addQuery('sys_updated_on', '>=', gdtStart);
    gr1.addQuery('sys_updated_on', '<=', gdtEnd);
    gr1.query();
 
   
 
    while (gr1.next()) {
        var grjournal = new GlideRecord("sys_journal_field");
    grjournal.addQuery("name", "incident");
    grjournal.addQuery('element_id',gr1.sys_id);
    grjournal.addQuery('element','work_notes');
    //grjournal.addQuery('sys_created_on',">=",gs.daysAgoStart(5));
    grjournal.orderByDesc('sys_created_on');
    grjournal.setLimit(1);
    grjournal.query();
    if (grjournal.next()) {
        gs.eventQueue('Incident.not.updated.for.5.days',gr1,'');
    }
    }
 
}(current, previous);