### Description
Display active alerts around services and applications in a compact view. The Service Alerts Rotator widget cycles through any service outages or planned maintenance windows. You can customize and style this widget using the available instance options and associated custom templates.
### Configuration
The instance options allow you to specify a page, custom classes for the column, and custom classes for the parent element. As well as change the color of the panel heading, customize the title, and select which image field should be used to display category images.
First, install the widget then access the widget's instance options menu (CTRL + Right click) and select Instance Options. You must specify an API in the API Name field. An example of the API that is needed for the widget is listed below under 'Dependencies'.
### Instance Options
| Option | Property | Comments | Default Value | Source |
| ----- |:-----:| ---- | ---- | ---- |
| Template | `u_template` | This property allows a custom template to be selected. | `Default value` | Instance |
| Carousel interval | `carousel_interval` | This field specifies the length of time in milliseconds, which should elapse between the display of each outage. | `5000` | Instance |
| Script Include | `script_include` | Supports overriding the default Script Include. | `Default value` | Options Schema |
| Always Show | `always_show` | Toggle the display of the widget. | `Default value` | Options Schema |
| No errors message | `no_errors_message` | Toggle ‘no error’ messages. | `Default value` | Options Schema |
| Page | `sp_page` | This property can be used to select a page which is used for creating the URL for each category. | `Default value` | Instance |
### Templates
| Name | Comments |
| -------- |:---|
| `alert.html` | Displays the set alert message. |
### Configuration
```json
{
"data": {
"query": "cmdb_ci.sys_class_name=cmdb_ci_service",
"always_show": "true",
"api": "FOO",
"templateID": "alert.html"
}
}
```
### Dependencies
_Dependencies are included and configured as part of the provided Update Set._
This widget uses a script include. (Make sure to include the name of the script include in the API Name field of the instance options)
To install this API, access the sys_script_include table and create a new record that uses this script, then place the name of the API that you created in the API Name field of the widget instance options.
```javascript
var AlertQuery = Class.create();
AlertQuery.prototype = {
initialize: function() {
},
getAlerts: function() {
var alerts = [];
var grOutage = new GlideRecord("cmdb_ci_outage");
grOutage.addQuery("cmdb_ci.sys_class_name", "cmdb_ci_service");
grOutage.addEncodedQuery("begin<=javascript:gs.endOfCurrentMinute()");
grOutage.addEncodedQuery("end>=" + gs.beginningOfCurrentMinute() + '^ORendISEMPTY');
grOutage.query();
while (grOutage.next()) {
var item = {};
item.displayType = grOutage.type.getDisplayValue();
item.type = grOutage.getValue("type");
item.message = grOutage.cmdb_ci.getDisplayValue();
item.serviceID = grOutage.getValue("cmdb_ci");
item.begin = grOutage.begin.getDisplayValue();
item.link = '?id=service_status&service=' + item.serviceID;
if(item.type == 'planned') {
item.icon = 'fa-clock-o';
item.labelClass = 'info';
} else if(item.type == 'outage') {
item.icon = 'fa-warning';
item.labelClass = 'danger';
} else {
item.icon = 'fa-arrow-circle-down';
item.labelClass = 'warning';
}
alerts.push(item);
}
return alerts;
},
getQuery: function() {
var query = "cmdb_ci.sys_class_name=cmdb_ci_service";
return query;
},
getTable: function() {
var table = 'cmdb_ci_outage';
return table;
},
type: 'AlertQuery'
};
```