UI Action for detecting if Change record Ci is attached to any open incident already.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2024 07:49 AM
Hi All,
We have an requirement to create UI action visible on assess state if Change record Ci is attached to any open incident already then it will give a info message on change request form that like "This CI is already attached to an open Incident : INC001202.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2024 08:34 AM
I'm not sure I fully understand. Why would you want to alert on a Change Record that a CI is associated with an incident? Most likely that would make sense because the change could be fixing the incident.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2024 08:58 AM
Hi @Gk1503 ,
You can achieve this using the sample code available below:
var getDetails = checkIncidentCI();
gs.addInfoMessage('This CI is already attached to an open Incident :' + getDetails);
action.setRedirectURL(current);
function checkIncidentCI(){
var incArr = [];
var inc = new GlideRecord('incident');
inc.addQuery('cmdb_ci',current.cmdb_ci);
inc.query();
while(inc.next()){
incArr.push(inc.number.toString());
}
return incArr;
}
Add a condition to the UI action as below to validate the assess state:
current.state == -4
Result:
Regards,
Shloke