Multiple requested item using MRVS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 12:38 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 12:43 AM
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
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
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 12:52 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 12:56 AM
if 3 rows then For Each should run 3 times and not 4 times
Please test again
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 01:04 AM - edited 09-14-2023 01:04 AM
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.