Custom Related list - Scripted relationship

Kiran Patil3
Giga Expert

Hi,

We are trying to build custom related list for Problem Management. We need to display Incident outages under problem for all related Incident to the current problem.

Custom field was added cmdb_ci_outage table to refer related Incident. Lets say Problem has 3 Incident related and each Incident has 1 outage record so Incident outage related list on problem should show 3 records.

We have added custom script and created relationship for Incident outage. Here the screen shot.

 

find_real_file.png

But somehow it returns only one outage record related to first incident in array. Any other way to achieve this.

We dont want to create duplicate records of outages in cmdb_ci_outage table for Incident and problem.

 

 

1 ACCEPTED SOLUTION

Kiran Patil3
Giga Expert

Corrected the code and its working now.

 

	var incidents = [];
	var incs = new GlideRecord('incident');
	incs.addQuery('problem_id',parent.sys_id);
	incs.query();
	while(incs.next())
		{
		incidents.push(incs.getValue('sys_id'));
		}
	
	current.addEncodedQuery('u_impacted_recordIN'+ incidents);
	gs.info(incidents);

View solution in original post

2 REPLIES 2

Kiran Patil3
Giga Expert

Corrected the code and its working now.

 

	var incidents = [];
	var incs = new GlideRecord('incident');
	incs.addQuery('problem_id',parent.sys_id);
	incs.query();
	while(incs.next())
		{
		incidents.push(incs.getValue('sys_id'));
		}
	
	current.addEncodedQuery('u_impacted_recordIN'+ incidents);
	gs.info(incidents);

Rupesh Ram Chi1
Tera Contributor

How does your incident and problem, cmdb outage forms look like ?