List Collector to Populate Affected CI's Related List

stvillil
Kilo Contributor

Hi Everyone!

I have a requirement to add in a glide list field on the change form (the list collector with a lock in it) to populate the affected CIs related list.

I copied modified two business rules that is populating the related list, but it is adding the first choice over and over again and not adding the other CIs. I'm thinking I'd have to copy and modify the script include "ChangeCollisionHelper". Any ideas?


Sync CI in affected Cis List Picker



if (!previous.u_additional_affected_cis.nil())
removePreviousCI();

if (!current.u_additional_affected_cis.nil())
addCurrentCI();

function removePreviousCI() {
// Delete Affected CI records for this task and previous CI
var rec = new GlideRecord('task_ci');
rec.addQuery('task', current.sys_id);
rec.addQuery('ci_item', previous.u_additional_affected_cis);
rec.query();
while (rec.next())
rec.deleteRecord();
}

function addCurrentCI() {
//Create Affected CI record for this task and current CI
var rec = new GlideRecord('task_ci');
rec.addQuery('task', current.sys_id);
rec.addQuery('ci_item', current.u_additional_affected_cis);
rec.query();
if (rec.next())
return;

rec.initialize();
rec.task = current.sys_id;
rec.ci_item = current.u_additional_affected_cis;
rec.insert();
}



Add CI in affected Cis List Picker



perform();

function perform(){
if(!ChangeCollisionHelper.isCiInAffectedCis(current.u_additional_affected_cis,current.sys_id)){
ChangeCollisionHelper.addCiToChangeAffectedCis(current.u_additional_affected_cis,current.sys_id);
}
}




Thanks in advance for any help you can provide.

9 REPLIES 9

parik_narain
Kilo Explorer

Hi

You can leverage the functionality provided within the system.

The affect CI addition to a Change is already available through BSM map.Go to the CI on the map and select 'Add Affected CI' from the context menu.
Each selected CI will be added to the 'Affected CI' list on the change.
Affected CIs can be removed from the list through the 'Edit' option.

Is there a restriction/limitation within CMDB data/relationships which you are trying to address with the above scripts?

Regards
Parik


I could not find the 'Add Affected CI' from the context menu.

stvillil
Kilo Contributor

Hi Parik,

Thanks for the quick response and great suggestion. The requirement is to keep the user on the same page, with having to leave or save the change record before being able to add additional CIs.


stvillil
Kilo Contributor

Anyone...?