
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 04:10 AM - edited 10-03-2023 10:21 PM
Hi,
I want outage to be created from incident using create outage context menu option. Tried below script in create outage ui action but its not working.
function outageAlreadyExists() {
var outageGr = new GlideRecord('cmdb_ci_outage');
outageGr.addQuery('task_number', current.sys_id);
outageGr.query();
return outageGr.hasNext();
}
var outageExists = outageAlreadyExists();
createOutageM2M(outageExists);
function createOutageM2M(outageExists) {
if (!outageExists) {
current.update();
var url = new CreateOutageUtil().getNewOutageLink(current);
action.setRedirectURL(url);
action.setReturnURL(current);
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 05:14 AM
Hi @Community Alums
You can try the following way to hide the Create outage option if there is an Outage already exists with that Incident.
1. Create a Script Include like the one below:
function checkIfOutageExists(inc){
var outageGr = new GlideRecord('cmdb_ci_outage');
outageGr.addQuery('task_number', inc);
outageGr.query();
if(outageGr.next()){
return false;
}
return true;
}
2. Now add this to condition field in UI Action as shown below:
(OOTB UI Action SYS_ID is : 18edfe530a0006d401d579b8ca27b3f1)
(current.getRecordClassName() == 'incident' || current.getRecordClassName() == 'problem') && current.active && checkIfOutageExists(current.sys_id)
Please mark my answer helpful and accept as solution if it helped you 👍✔️
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 05:14 AM
Hi @Community Alums
You can try the following way to hide the Create outage option if there is an Outage already exists with that Incident.
1. Create a Script Include like the one below:
function checkIfOutageExists(inc){
var outageGr = new GlideRecord('cmdb_ci_outage');
outageGr.addQuery('task_number', inc);
outageGr.query();
if(outageGr.next()){
return false;
}
return true;
}
2. Now add this to condition field in UI Action as shown below:
(OOTB UI Action SYS_ID is : 18edfe530a0006d401d579b8ca27b3f1)
(current.getRecordClassName() == 'incident' || current.getRecordClassName() == 'problem') && current.active && checkIfOutageExists(current.sys_id)
Please mark my answer helpful and accept as solution if it helped you 👍✔️
Anvesh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 05:32 AM - edited 10-03-2023 10:21 PM
not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 05:51 AM
@Community Alums Can you try the Script Include code and name I Provided as is and the condition too?
Anvesh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 05:59 AM
Hi, tried with same script and added condition too in ui action , but still i can see create outage option eventhough outage is already created.