The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Related List to display all affected CI records

harishdasari
Tera Guru

Hi,

In change request, when user adds additional CI's in related list affected CI tab, Then it should fetch all the records like incident, Problem, change and it should get displayed in the newly created section called "Related affected CI record".

any one please let me know how can I achieve this

Thank you

Michael.Fry   kalai

10 REPLIES 10

marcguy
ServiceNow Employee
ServiceNow Employee

My one worry about this is you would be querying the task table quite extensively for only sometime results, it may cause you some performance problems whilst loading the related lists.



but in essence you would query the task_ci table for the affected CIs, then for each CI add it's sys_id to a query on task where that CI is the cmdb_ci on a task.




var ids = '';


var tci = new GlideRecord('task_ci');


tci.addQuery('task',parent.sys_id;


tci.query();


while(tci.next()){


ids += tci.ci_item+',';


}



task table would be the table to query from


current.addActiveQuery();


current.addQuery('cmdb_ci','IN',ids);



query all tasks where any of my affected CIs are the active CI in that task. As I say that would be a rather long query and there may be a better way to do this on demand via an icon rather than a constant related list.