I have a list collector variable. When i select multiple values in list collector variable it should be able to create multiple RITM's and copy the variables and workflow to all the RITM's raised. Could anyone provide solution for this.

hemanthsnowdeve
Tera Contributor
 

@Ankur Bawiskar @Aman Kumar @Jaspal Singh @Mark Roethof 

Could you please provide your inputs on the question. Please let me know if you need any clarity.

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Is that a business requirement to create multiple RITMs and copy?

You can use workflow run script and iterate over the list and use Cart API to create RITM and copy the variable

Scripting for the ServiceNow Cart

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

Yes it is a business requirement. 

I want the values filled in the particular variable to be automatically populated from catalog form. The script below is setting the variable.

cart.setVariable(RITM,'ram','16');       /**/
cart.setVariable(RITM,'os','win10');     /* Catalog item variables can be populated */  
cart.setVariable(RITM,'storage','1tb');  /**/

Hi,

something like this

Note: I think you might have to explore what happens when MRVS is present; I haven't checked for that

var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
//add your requested item to the cart by sys_id of the catalog item
var item = cart.addItem('catalogItemSysId', 1);

// iterate over the variables
var variables = current.variables.getElements(); 
for (var i=0;i<variables.length;i++) { 
	var question = variables[i].getQuestion(); 
	var name = question.getName();
	if(name != '')
		cart.setVariable(item, name, current.variables[name]);
}
var rc = cart.placeOrder();

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader