Get Affected CIs

Anjaneyulu1
Giga Contributor

Hii All,

In Incident record, there is a related list of Affected CIs. Create a field in Incident form named ‘Affected Cis’ of LIST type which should refer to cmdb_ci table and it should have only those CIs as option to select which are listed in Affected CIs related list.

I have written script include like this

getCIs: function() {
var CIs = '';

var AffectedCIs = current.task_ci;
var getCIs = new GlideRecord('task_ci');
getCIs.addQuery('ci_item', AffectedCIs);
getCIs.query();
while (getCIs.next()) {
CIs += ',' + task.sys_id;
}
return 'sys_idIN' + CIs;

 


},

 

And also i used advanced Reference Qualifier as

javascript:new afftectedCIs().getCIs();

but it is not showing records.

Please help me on this requirement.

1 ACCEPTED SOLUTION

Hi @Anjaneyulu Nalamothu ,

 

Replace the below code in script include

 

getCIs: function(current) {
var CIs = [];
var task = current.sys_id;
var getCIs = new GlideRecord('task_ci');
getCIs.addQuery('task', task);
getCIs.query();
while (getCIs.next()) {
CIs.push(getCIs.ci_item.sys_id);
}
return 'sys_idIN' + CIs;
},

 

Pease mark the response as Helpful/Correct, if applicable. Thanks!

View solution in original post

4 REPLIES 4

Maik Skoddow
Tera Patron
Tera Patron

Hi @Anjaneyulu Nalamothu ,

sorry but this makes no sense. Why do you want to have a field with redundant data? What is the underlying business requirement for that?

And what if the related list changes? How do you want to keep both lists in sync?

Kind regards
Maik

Nikita30
Mega Sage

Hi @Anjaneyulu Nalamothu ,

 

Please include the highlighted text in below code.

 javascript:new afftectedCIs().getCIs(current);

Script include

getCIs: function(current) {

var AffectedCIs = current.task_ci;
var getCIs = new GlideRecord('task_ci');
getCIs.addQuery('ci_item', AffectedCIs);
getCIs.query();
while (getCIs.next()) {
CIs += ',' + task.sys_id;
}
return 'sys_idIN' + CIs;
},

 

 

Please mark the response as Helpful/Correct, if applicable. Thanks!

Hii Nikita,

as you said I have done.

But still it is not showing Records.

Hi @Anjaneyulu Nalamothu ,

 

Replace the below code in script include

 

getCIs: function(current) {
var CIs = [];
var task = current.sys_id;
var getCIs = new GlideRecord('task_ci');
getCIs.addQuery('task', task);
getCIs.query();
while (getCIs.next()) {
CIs.push(getCIs.ci_item.sys_id);
}
return 'sys_idIN' + CIs;
},

 

Pease mark the response as Helpful/Correct, if applicable. Thanks!