- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 12:15 AM
Hello All,
I want to create an alert when an user is trying to raise an incident based on a configuration item which is having an current outage. So I write a client script and script include. But the alert is still not showing.
Client script:-
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 12:21 AM - edited 03-19-2024 12:24 AM
Hi @I_Das ,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 12:21 AM - edited 03-19-2024 12:24 AM
Hi @I_Das ,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 02:12 AM
Hello @Arun_Manoj ,
It worked. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 02:11 AM
Client Script:-
function onSubmit() {
var configItem = g_form.getValue('cmdb_ci');
var hasOutage = new GlideAjax('CheckOutageScriptInclude').getXMLWait(configItem);
if (hasOutage == 'true') {
alert('This CI has an outage.');
return false; // Prevent form submission
}
return true; // Allow form submission
}
Script Include:-
var CheckOutageScriptInclude = Class.create();
CheckOutageScriptInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getXMLWait: function(configItem) {
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();
if (outageGr.next()) {
return true;
}
return false;
}
});
Please mark this comment as if it helped you.
Regards,
Samiksha Gunjate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 02:24 AM - edited 03-19-2024 02:48 AM
Hello @Arun_Manoj ,
But before I also created a business rule on incident table where if one P1 incident will be raised an outage will automatically create. Though this is working to create alert that business rule is not triggering. How can I solve that issue?
My actual requirement was when a major incident will be raised an outage will be created automatically. Now if another user tries to raise incident based on the same configuration item which has outage ongoing it will create alert on portal.