Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to get list of affected CI of change request using script?

ritesh1
Tera Contributor

I want to get a list of all the affected CI for a particular Change Request using script. In the below screenshot, I need to get the list of affected CI (here ANNIE-IBM and JON-IBM) for the change request CHG0040007. How can I get these using glide/script?

 

find_real_file.png

1 ACCEPTED SOLUTION

Sulabh Garg
Mega Sage

Hello

Use the below script

var grTaskCi = new GlideRecord('task_ci');
grTaskCi.addEncodedQuery("task=d71a36101b4185106c080e1dcd4bcb3c");  //sys id of change
grTaskCi.query();
while (grTaskCi.next()) {
gs.info('ci_item: ' + grTaskCi.getValue('ci_item'));
}

Hope it helps.

 

Please Mark Correct/helpful, if applicable, Thanks!! 

Regards

Sulabh Garg

Please Mark Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg

View solution in original post

1 REPLY 1

Sulabh Garg
Mega Sage

Hello

Use the below script

var grTaskCi = new GlideRecord('task_ci');
grTaskCi.addEncodedQuery("task=d71a36101b4185106c080e1dcd4bcb3c");  //sys id of change
grTaskCi.query();
while (grTaskCi.next()) {
gs.info('ci_item: ' + grTaskCi.getValue('ci_item'));
}

Hope it helps.

 

Please Mark Correct/helpful, if applicable, Thanks!! 

Regards

Sulabh Garg

Please Mark Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg