How to add incident/problem/ change to Ci's respective related list tabs ?

DusmantaN
Tera Contributor

Hi,

->I have a requirement to add incident/ Problem/ change records to the Ci's respective related list tabs, if the ci is added in the affected CIs related list. If I add ci to affected CIs, in that ci's related list I want to add the Incident/problem/ change to their respective tabs. 

 

I have created one BR: after Insert Business Rule on the task_ci 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);

 

 

Next created a Relationship.   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);

 

 

Can anyone please suggest. how to achieve this?

Regards,

Dusmanta

1 REPLY 1

Brian Lancaster
Tera Sage

You can use the affected by task related list. 

BrianLancaster_0-1723735455849.png