- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 02:14 PM
Hello,
When a new incident is being created, i want to know what active outages exist in the environment so that I do not create duplicate tickets and can provide details to users reporting the same issue.
When an outage is active and a user is viewing an Incident form via the frameset, a banner message appears at the top of the form explaining that there is currently an outage. This banner should also display the affected CI and the time the outage began.
Has anyone done something like this? Any input is appreciated.
Thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 06:21 PM
Try using this and it should work
(function executeRule(current, previous /*null when async*/) {
// Add your code here
gs.addInfoMessage('Entering Business Rule to display outage');
var now = new GlideDateTime(gs.nowDateTime());
var outage = new GlideRecord("cmdb_ci_outage");
outage.addQuery('type', 'Outage');
outage.addQuery("begin", "<=",now);
outage.addQuery("end", ">",now).addOrCondition("end", "=", "NULL");
outage.setLimit(5);
outage.query();
if (outage.next()) {
gs.addInfoMessage('Entering outage check to get CI value');
var outageci = outage.cmdb_ci.getDisplayValue();
gs.addInfoMessage("This is a test for outage");
gs.addInfoMessage("Outage opened for " + outageci);
}
})(current, previous);
Hope this helps
Mark this response as correct if that really helps
Thanks,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 05:34 PM
Hi Bryan,
So i have created a business rule for display with the following code. However it is not working as expected. I am trying to display the outage along with the affected CI. I have created an outage as Email with a begin date and time. But it is not displaying it when the incident is created. It is only displaying the message 'Entering Business Rule to display outage'. Any idea where i am going wrong.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
gs.addInfoMessage('Entering Business Rule to display outage');
var outage = new GlideRecord("cmdb_ci_outage");
outage.addQuery('type', 'Outage');
outage.addQuery("begin", "<=", gs.nowDateTime());
outage.addQuery("end", ">", gs.nowDateTime()).addOrCondition("end", "=", "NULL");
outage.setLimit(5);
outage.query();
if (outage.next()) {
gs.addInfoMessage('Entering outage check to get CI value');
var outageci = outage.cmdb_ci.getDisplayValue();
gs.addInfoMessage("This is a test for outage");
gs.addInfoMessage("Outage opened for " + outageci);
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 05:50 PM
Hi,
I'm recommend a few things for troubleshooting
1) maybe variable outage isn't a good choice? Just in case it's one of those global prohibited ones?
2) Have you tested this in background script just to see what you get?
3) Perhaps start easy with the query just to ensure it's working without going full in
4) I've seen others do the .addOrCondition little add-on there, but you may need to look at doing it the other way:
var outageOR = outage.addQuery("end", ">", gs.nowDateTime());
outageOR.addOrCondition("end", "=", "NULL");
5) try maybe doing: ('end', '');
6) Make a statement where if it doesn't find anything, then do this...
so like if (!outage.next()) {
gs.addInfoMessage("I didn't find anything");
}
See if any of those help?
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 06:21 PM
Try using this and it should work
(function executeRule(current, previous /*null when async*/) {
// Add your code here
gs.addInfoMessage('Entering Business Rule to display outage');
var now = new GlideDateTime(gs.nowDateTime());
var outage = new GlideRecord("cmdb_ci_outage");
outage.addQuery('type', 'Outage');
outage.addQuery("begin", "<=",now);
outage.addQuery("end", ">",now).addOrCondition("end", "=", "NULL");
outage.setLimit(5);
outage.query();
if (outage.next()) {
gs.addInfoMessage('Entering outage check to get CI value');
var outageci = outage.cmdb_ci.getDisplayValue();
gs.addInfoMessage("This is a test for outage");
gs.addInfoMessage("Outage opened for " + outageci);
}
})(current, previous);
Hope this helps
Mark this response as correct if that really helps
Thanks,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2024 02:28 PM
@siva_ please how do I make this code display more than 1 CI outage, this code is working for me but only 1 outage gets displayed. Please help help.