Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Is it possible to create multiple change requests from one record producer?

KellyK768068033
Tera Contributor

Is it possible to create multiple change requests from one record producer?

We are looking for a way to stream line submissions of change requests in instances where the same change applies to multiple CI's.

I've added a List Collector to my record producer and need to create one new change request for each value selected.

For example, user selectes 3 values in the list collector:   Value 1, Value 2, Value 3.   After the user populates all other required fields and clicks submit I need 3 distinct change requests to be created with CR 1 populated with Value 1, CR 2 pop'd with Value 2, etc

Kelly

1 ACCEPTED SOLUTION

him001
ServiceNow Employee

Hi Kelly,


It is possible to create multiple change_request from a single record producer. I have tested this as below:



1. Create a record producer which looks like:


Screen Shot 2017-08-24 at 1.26.55 AM.png



Script in the image is (can paste directly 😞


------------------------------------------------------------------------------------


var numOfConfigItems = [];


if (producer.list_collector) {


numOfConfigItems = producer.list_collector.toString().split(','); // get list of cmdb_items


}



for (var i = 0; i < numOfConfigItems.length; i++) {


current.initialize();


current.short_description = "test";   // This is how common properties will be set for the change_requests


current.cmdb_ci = numOfConfigItems[i];


current.insert();


}


current.setAbortAction(true);   // default insert stop


--------------------------------------------------------------------------------------



2. Create a variable (which I think you have already created), which is of list collector type (name = "list_collector" used above).



3. Above example creates change requests with description as "test" for each ci_item.



Hope this helps.



Thanks,


Himanshu


View solution in original post

3 REPLIES 3

rohantyagi
ServiceNow Employee

Yes, its possible. Check the discussion below:


How to Create a dynamic change task from a list collector


him001
ServiceNow Employee

Hi Kelly,


It is possible to create multiple change_request from a single record producer. I have tested this as below:



1. Create a record producer which looks like:


Screen Shot 2017-08-24 at 1.26.55 AM.png



Script in the image is (can paste directly 😞


------------------------------------------------------------------------------------


var numOfConfigItems = [];


if (producer.list_collector) {


numOfConfigItems = producer.list_collector.toString().split(','); // get list of cmdb_items


}



for (var i = 0; i < numOfConfigItems.length; i++) {


current.initialize();


current.short_description = "test";   // This is how common properties will be set for the change_requests


current.cmdb_ci = numOfConfigItems[i];


current.insert();


}


current.setAbortAction(true);   // default insert stop


--------------------------------------------------------------------------------------



2. Create a variable (which I think you have already created), which is of list collector type (name = "list_collector" used above).



3. Above example creates change requests with description as "test" for each ci_item.



Hope this helps.



Thanks,


Himanshu


How to do you add attachment to the multiple records you created from the script?