Notification to owned by

Community Alums
Not applicable

Hello Team,

I need to trigger the Notification when ownership is MIT and no outage is der on change table , for the affected Cis and AffectedCis services to owned by , manged by and Approval group .


I have Written the Business rule :-

Table :- Change_request
after business rule -- Update
condition is :- ownership is MIT

Code :-
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
if (!current.outage) { // Assuming 'outage' is a field on the change_request table
// Send notification
gs.addInfoMessage('current.owned_by').
gs.eventQueue('custom.change.no.outage', current, current.owned_by, current.managed_by);
}
})(current, previous);

Event Created with the name :-
custom.change.no.outage

and The
Notification Name : :- Send Notification for Outage
send when :- event is fired .
event name :- custom.change.no.outage.

Still i am not able to trigger the notification to owned by , manged by and approval group for affecteds CIs and Affected services.

Please advise me on this and correct the above code

1 REPLY 1

Anand Kumar P
Giga Patron
Giga Patron

Hi @Community Alums ,

If you want to to trigger notification for affected user then query cmdb_ci table

(function executeRule(current, previous /*null when async*/ ) {
    if (current.ownership == 'CIT' && !current.outage) {
        var affected_ci= new GlideRecord('cmdb_ci'); 
        affected_ci.addQuery('sys_id', 'IN', current.affected_cis);
        affected_ci.query();
        while (affected_ci.next()) {
            gs.eventQueue('custom.change.no.outage', current, affected_ci.owned_by, affected_ci.managed_by, affected_ci.approval_group);
        }
    }
})(current, previous);

Please mark it solution proposed and helpful if it works for you.

Thanks,

Anand