How to add incident to Ci's Incident related list if the ci is added in the outages

MS17
Tera Contributor

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?

 

rl.PNG

 

rl2.PNG

1 ACCEPTED SOLUTION

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.

 

View solution in original post

6 REPLIES 6

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. 

Thanks Brad! Is there any other way to achieve this requirement?