Notification Needs to trigger for no outage

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2023 02:07 AM - edited ‎10-10-2023 08:00 AM
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 .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2023 02:22 AM
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:gs.beginningOfToday()@javascript:gs.endOfToday()&sysparm_first_row=1&sysparm_view=
What is the type of the field "outage" represented in your script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2023 02:27 AM
@Tai Vu outage is checkbox in change_request . please check above script written
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2023 03:05 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2023 06:21 AM - edited ‎10-10-2023 10:25 PM
@Tai Vu Its not working for me . Please advise.