Using REST API, how to add CIs to a Change Request?

kenward
Kilo Explorer

I have an existing Change Request and multiple existing CIs. Using REST, I want to add several CIs to the change. Can someone describe the process?

3 REPLIES 3

Sashi K1
Kilo Guru

Hi Ken


by process every change is created against impacted CI. So there will be on CI at Change level. You can add multiple affected CIs for each change. For that you can query table task_ci and add multipel CIs for each Change Request which would be displayed on the related section of Change request form. Task_CI table has task type which is key to make relationship across CIs for each Change.



Are you looking at this or you want a sample REST code that could add multipel affected CIs to a Change?



Thanks


If you had sample REST code, that would be great. But what I'm looking for is the REST calls I need to do to add each CI.


I expect it would be multiple REST calls, to do lookups and then adds. So something like, required JSON params, GET from table_name.



Thanks!


Using Rest out of the box we can't make bulk updates, you may have to make individual record inserts for each affected CI.


To achieve it I would recommend to use Custom Processors. You can make Rest call to a custom process by passing URL parameters as Change Id, and list of affected CIs as comma separated. Use custom processor script to read through each affected CI update Change record.



Tutorial 4 Creating a Custom Processor - ServiceNow Wiki



This is how you would use one Rest call to update in bulk.