Notifications are not triggered as per configs

shivikayada
Tera Contributor

ISSUE:
We understand that your Notifications are not triggering as per configs

SOLUTION PROPOSED:
We investigated and identified that the email notification "MTH SCTask Group Assigned (LIMS)" created on the SC_TASK table is being sent out when 'sc_task.assigned.to.local_it_mgr.group' event is fired.
This event is fired from the

'https://britishcouncil.service-now.com/nav_to.do?uri=sys_script.do?sys_id=037d66e0c0a801020161091ecb...'

Business Rule - from line number 26.
The business rule is triggering the event correctly at the required time.

We understood that this business rule is calling a Script Include 'SPOCCMDBUtils'

[https://britishcouncil.service-now.com/nav_to.do?uri=sys_script_include.do?sys_id=53d24bbadbc82b0037...

"ITManagersForCallerLocation" function which is defined in line number 553.

This Script Include is in turn calling another Script Include 'SPOCUtils'

[https://britishcouncil.service-now.com/nav_to.do?uri=sys_script_include.do?sys_id=26367e95db4c5b0037...

"getGroupMembers" function which is defined in line number 525.

4 REPLIES 4

palanikumar
Mega Sage

Hi @shivikayada ,

 

Don't share URL of your environment as it is not accessible for others. Share the lines of code and explain what is the issue

 

Thank you,

Palani

Thank you,
Palani

Ankur Bawiskar
Tera Patron
Tera Patron

@shivikayada 

please share the configurations you did and what troubleshooting you performed?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Rakesh18081
Tera Expert

@shivikayada  Please share the screenshot so that required help can be delivered.

 

Regards

Rakesh

shivikayada
Tera Contributor

Hi All, please help analyse the issue, as the local IT managers should only receive notifications of SCTASKS/INC.CHG/PRB/PTASK/CTASK assigned to them, based on the impacted location

 

They are receiving the notifications from across the globe.

 

Event- sc_task.assigned.to.local_it_mgr.group, getting fired from below BR-

if (current.operation() != 'insert' && current.comments.changes()) {
   gs.eventQueue("sc_task.commented", current, gs.getUserID(), gs.getUserName());
}

if (current.operation() != 'insert' && current.work_notes.changes()) {
   gs.eventQueue("sc_task.worknoted", current, gs.getUserID(), gs.getUserName());
}

if (current.operation() == 'update') {
   gs.eventQueue("sc_task.updated", current, gs.getUserID(), gs.getUserName());
}

if (current.state.changes() ) {
   gs.eventQueue("sc_task.state.changed", current, current.state, previous.state);
}

if (current.assigned_to.changes() || current.work_start.changes()) {
   gs.eventQueue("sc_task.assigned.to.user", current, current.assigned_to.getDisplayValue() , previous.assigned_to.getDisplayValue());
}

if (!current.assignment_group.nil() && current.assignment_group.changes() && current.assignment_group.getDisplayValue() != 'Local IT Manager Support') {
   gs.eventQueue("sc_task.assigned.to.group", current, current.assignment_group.getDisplayValue() , previous.assignment_group.getDisplayValue());
}

//extra notification sent to local it manager which are having one of locations matches caller location
if (!current.assignment_group.nil() && current.assignment_group.changes() && current.assignment_group.getDisplayValue() == 'Local IT Manager Support') {
  gs.eventQueue("sc_task.assigned.to.local_it_mgr.group", current, new SPOCCMDBUtils().ITManagersForCallerLocation(current.request.requested_for.location) , previous.assignment_group.getDisplayValue());
}
Script Include- SPOCCMDBUTILS, from lines 553-572

ITManagersForCallerLocation: function(callerLocation) {

        var answer = [];

        var itManagerGroupMmebers = new SPOCUtils().getGroupMembers('Local IT Manager Support');

        for (var i = 0; i < itManagerGroupMmebers.length; i++) {

            var managerLocations = this.getUserLocations(itManagerGroupMmebers[i]);

            if (managerLocations.toString().indexOf(callerLocation) != -1) {

                var userEmail = new SPOCUtils().getUserEmail(itManagerGroupMmebers[i]);
                answer.push(userEmail);

            }

        }

        return answer;
 
Script Include- SPOCUTILS, from lines 525-541-
 
//return members (sys_id) of the group being provided
    getGroupMembers: function(groupName) {

        var answer = [];
        var gr = new GlideRecord('sys_user_grmember');
        gr.addQuery('group.name', groupName);
        gr.addNotNullQuery('user');
        gr.addNotNullQuery('group');
        gr.query();
        while (gr.next()) {

            answer.push(gr.user.sys_id.toString());

        }

        return answer;

    },