Multiple requested item using MRVS

Sarika S Nair1
Kilo Sage

Hi, 

I have a catalog item with one multi row variable set.I want to create multiple requested item based on number of rows in the MRVS.Suppose there are 3 rows in the MRVS, then i need 3 requested item tagged under one request.

How can i achieve this?

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

@Sarika S Nair1 

you must be using either workflow or flow designer, here are the approaches

1) workflow

-> use run script, parse the MRVS JSON and get the count of rows and then use cart API or CartJS API

CartJS 

var parsedData = JSON.parse(current.variables.mrvsVariableSetName);

var count = parsedData.length;

for(var i=0;i<count;i++){
	// use Cart API

	try{

		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('0336c34407d0d010540bf2508c1ed096', 1);

		//fill in the variables on the request item form
		cart.setVariable(item, "asset", "00a96c0d3790200044e0bfc8bcbe5dc3");
		cart.setVariable(item, "multiple_choice", "Phoenix");
		var rc = cart.placeOrder();
		gs.info(rc.number);

	}
	catch(ex){
		gs.info(ex);
	}
}

2) Flow designer

-> iterate the MRVS rows using FOR EACH and within that FOR Each use Submit Catalog Item Request action

AnkurBawiskar_0-1694677340718.png

Submit Catalog Item Request action 

I believe I have provided answer to your question. You can enhance it further based on your requirement.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi @Ankur Bawiskar 

when i use submit catalog item request action, it is adding new requested item tagged in different request.So i have used create record method to add multiple requested item..but it creating one additional requested item..Suppose there are 3 rows in the MRVS, it is creating 4 requested item.Attaching the screenshot of the Flow which i used.. Please suggest.

Sarika12_0-1694677909421.png

 

@Sarika S Nair1 

if 3 rows then For Each should run 3 times and not 4 times

Please test again

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

Hi Ankur,

By default one requested item is creating when we submit the catalog item..and then this for each loop is running and creating extra requested items. Please suggest how to get rid of the default requested item creation.