- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-23-2020 04:07 AM
Hi
I have a requirement, where I have to create multiple request items under a single request using one catalog form.
If the User has selected check-boxes then request item has be created, if does not check any of check-boxes then one RITM has be created.
Requirement is something similar to the Order Guide - New Hire
Thanks,
Kumar
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-23-2020 06:15 AM
you have to first identify here the number of check box have been checked and based on that using for loop you can create the extra RITM on your request.
Adding Sample code here. use the below code on your workflow run script activity, Give a try.
var dd = current.variables.check_box;
var dd1 = current.variables.check_box1;
var dd2 = current.variables.check_box2;
var mandatoryVars = [dd,dd1,dd2];
var numTrue = 0;
for (var x = 0; x < mandatoryVars.length; x++) {
if (mandatoryVars[x] == 'true') {
numTrue ++;
}
}
for(var i = 0 ; i< numTrue ; i ++){
var gr = new GlideRecord('sc_req_item');
gr.initialize();
gr.cat_item = current.cat_item;
gr.request= current.request;
gr.insert();
}
If my answer helped you, kindly mark it as correct and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-16-2024 06:47 AM
Where should this code be placed ?
if this will be placed in workflow\run script activity this will create an infinite loop,
upon creation of new RITM the workflow will be called again and again ...
Am I missing something or our instance has different setup.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-21-2024 07:49 PM
@Simm - you can have this in workflow/flow designer(custom action), to avoid the infinite loop add the iteration logic to for loop.(In the above code we had the checkbox logic)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-21-2024 07:58 PM
Got it.
Thank you very much.
Perfect solution for my project now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-24-2024 12:49 AM
Abhit ,
I find it hard to find sample on different forum on
how to set the variables, could you post some sample
for(var i = 0 ; i< numTrue ; i ++){
var gr = new GlideRecord('sc_req_item');
gr.initialize();
gr.cat_item = current.cat_item;
gr.request= current.request;
//// How to set the Variables here before insert ?
gr.insert();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-03-2024 09:25 PM
@Simm - Are you trying to set the variables value of the request which you are creating it through script?
If yes then please you have to create a record on "sc_item_option" table then tag this record with RITM you need to create a record on "sc_item_option" table.
Or better use Cart API to submit the record if the business is fine with new REQ for each RITM and you can link initial RITM as parent to the new ones.
Regards,
Abhit.