The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Notification Needs to trigger for no outage

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 .

4 REPLIES 4

Tai Vu
Kilo Patron
Kilo Patron

Hi @Community Alums 

Have you checked the Event Queue to make sure the Event get fired and processed?
URL: https://<instance_name>/sysevent_list.do?sysparm_query=nameSTARTSWITHcustom.change.no.outage%5Esys_created_onONToday@javascript&colon;gs.beginningOfToday()@javascript&colon;gs.endOfToday()&sysparm_first_row=1&sysparm_view=

What is the type of the field "outage" represented in your script?

Community Alums
Not applicable

@Tai Vu  outage is checkbox in change_request  . please check above script written 

Hi @Community Alums 

So the business rule is triggered and the event get fired.

What currently missing is the Owned by [owned_by] and Managed by [managed_by] from the Affected CIs.

We need to do a query to this table Affected CIs [task_ci] to get these information.

Sample below.

var arrOwnedBy = [];
var arrManagedBy = [];
var grAffectedCI = new GlideRecord('task_ci');
grAffectedCI.addQuery('task', current.getUniqueValue());
grAffectedCI.addNotNullQuery('ci_item');
grAffectedCI.query();
while(grAffectedCI.next()){
    gs.log(grAffectedCI.ci_item.owned_by.toString() + ' - ' + grAffectedCI.ci_item.owned_by.getDisplayValue());
    gs.log(grAffectedCI.ci_item.managed_by.toString() + ' - ' + grAffectedCI.ci_item.managed_by.getDisplayValue());
    arrOwnedBy.push(grAffectedCI.ci_item.owned_by.toString());
    arrManagedBy.push(grAffectedCI.ci_item.managed_by.toString());
}

gs.eventQueue('custom.change.no.outage', current, arrOwnedBy.join(','), arrManagedBy.join(','));

 

Let me know if it works for you

 

Cheers,

Tai Vu

Community Alums
Not applicable

@Tai Vu  Its not working for me . Please advise.