Outage creation
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 01:34 AM
Hello all,
My requirement was
Outage is automatically created when a P1 is declared and Accepted, the Begin time of Outage is the Opened time of the incident'. Now when another incident is being created whose configuration item is having outage it will show alert.
I wrote client script and script include:
function onSubmit() { var configItem = g_form.getValue('cmdb_ci'); // Make a GlideAjax call to check if the CI has an outage
var ga = new GlideAjax('CheckOutageScriptInclude');
ga.addParam('sysparm_name', 'getXML');
ga.addParam('sysparm_cmdb_ci', configItem);
ga.getXMLAnswer(function(response) { if (response == 'true') {
alert('This CI has an outage. Incident cannot be raised.');
g_form.clearMessages(); // Clear any previous messages
return false; // Prevent form submission
} else
{
return true; // Allow form submission
} }); // Ensure the form submission is halted until the response is received
return false;
}
script include:
var CheckOutageScriptInclude = Class.create();
CheckOutageScriptInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getXML: function() {
var configItem = this.getParameter('sysparm_cmdb_ci');
var hasOutage = this._checkForOutage(configItem);
return hasOutage.toString();
}, _checkForOutage: function(configItem) {
var outageGr = new GlideRecord('cmdb_ci_outage');
outageGr.addQuery('cmdb_ci', configItem);
outageGr.addQuery('end', '>', new GlideDateTime());
outageGr.query(); return outageGr.hasNext();
} });
Now here in script includes how do I I replace "outageGr.addQuery('end', '>', new GlideDateTime());'. Because it is taking 'end' value when I give the end value in outage table manually. but I want a condition where the begin value which is created automatically from incident will be taken?
0 REPLIES 0