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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2022 08:34 PM
Could you please provide your inputs on the question. Please let me know if you need any clarity.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2022 08:41 PM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2022 08:46 PM
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'); /**/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2022 09:34 PM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader