- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 08:29 AM
Hi All,
->I need to add incident to the Ci's Incident related list, if the ci is added in the outages related list. If I add ci to outages, in that ci's related list I want to add the Incident number.
-> In the below images "*BOW-IBM" is added in Outages related list, I want to add the incident "INC0009009" to "*BOW-IBM" ci's incident related list.
Can anyone please suggest. how to achieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2023 05:01 AM
I was thinking something more like this for the after Insert Business Rule on the cmdb_ci_outage table:
(function executeRule(current, previous /*null when async*/ ) {
var affci = new GlideRecord ('task_ci');
affci.addQuery('ci_item', current.cmdb_ci);
affci.addQuery('task', current.task_number);
affci.query();
if (!affci.hasnext()) {
affci.initialize();
affci.ci_item = current.cmdb_ci;
affci.task = current.task_number;
affci.insert();
}
})(current, previous);
So on an incident, when an Outage record is created, you will now see a new record on the Affected CIs Related List on that same Incident with the CI used in the Outage - provided it wasn't already listed as an Affected CI, and the Configuration item field on the Incident remains unaffected.
Next create a Relationship. Name it whatever you want to appear on the tab. Applies to table = cmdb_ci. Queries from table = incident. Query with =
(function refineQuery(current, parent) {
var incArr = [];
var affci = new GlideRecord('task_ci');
affci.addQuery('ci_item', parent.sys_id);
affci.query();
while (affci.next()) {
incArr.push(affci.task.toString());
}
current.addQuery('sys_id', 'IN', incArr.join(','));
})(current, parent);
Once you add this new Related List to the CI form(s) you will see all of the incidents that have an Outage, and hence an Affected CI - or were otherwise added to the Affected CI Related List.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2023 07:14 AM
Unfortunately, OOTB Related Lists cannot be altered, and I have not found one that is doing something similar. With the Affected CI capabilty OOTB allowing for more than one CI to be associated to an Incident, this does seem like something that should be OOTB. Perhaps it's just an oversight for now. Also unfortunately, it seems like the related list will need to be added to every CI form. Since doing this action results in a view or record update somewhere, there may be a fancy way to script it for all cmdb_ci instance tables, but I don't know what that would be off the top of my head.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2023 09:17 AM
Thanks Brad! Is there any other way to achieve this requirement?