
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2022 08:48 AM
We have an Onboarding catalog item that is filled in via an inbound action. I was requested to make a sperate item for facilities as they want to put an SLA at the RITM Level for IT and facilities like to leave the tasks open. So I created a separate item for facilities which basically has the same variable. Now I'm trying to order these at the same time so they are part of the same request. I'm having trouble trying to figure out how to do this with CartJS. I have made several attempts but it always just add the first item to the cart but never submit it. Here is the code from the last attempt. Any idea on how to get this to work?
values.toString().split(',');
var cart = new sn_sc.CartJS();
var item = {
'sysparm_id': '5b776f111b04d010294520622a4bcbbe',
'sysparm_quantity': '1',
'variables': {
'first_name': values[0],
'middle_name': values[1],
'last_name': values[2],
'employee_id': values[3],
'employee_type': values[4],
'employee_manager': values[5],
'employee_manager_email': values[6],
'department': values[7],
'start_date': values[8],
'end_date': values[9],
'managment_level': values[10],
'work_location': values[11],
'work_hours': values[12],
'Manager Sup Org': values[13],
'Employee Sup Org': values[14]
}
};
var item2 = {
'sysparm_id': '2247874cdbea4950750993a6f49619a4',
'sysparm_quantity': '1',
'variables': {
'first_name': values[0],
'middle_name': values[1],
'last_name': values[2],
'employee_id': values[3],
'employee_type': values[4],
'employee_manager': values[5],
'employee_manager_email': values[6],
'department': values[7],
'start_date': values[8],
'end_date': values[9],
'managment_level': values[10],
'work_location': values[11],
'work_hours': values[12],
'Manager Sup Org': values[13],
'Employee Sup Org': values[14]
}
};
var cartDetails = cart.addToCart(item);
cartDetails = cart.addToCart(item2);
var checkoutInfo = cart.checkoutCart();
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2022 09:06 AM
I've tried something similar to your scenario which added me two different catalogs into cart and one request
for (i = 0; i < 2; i++) {
var cart = new sn_sc.CartJS();
if(i==0)
{
var item =
{
'sysparm_id': 'd66518691ba10910558d639bbc4bcbc0',
'sysparm_quantity': '1',
'variables':{
' details1': 'at_and_t_mobility',
}};
}
else
{
var item =
{
'sysparm_id': 'a9b30d601b7a3410558d639bbc4bcb3f',
'sysparm_quantity': '1',
'variables':{
'testing': 'at_a',
}};
}
var cartDetails = cart.addToCart(item);
gs.info(JSON.stringify(cartDetails));
}
var cartDetails = cart.orderNow(item);
gs.info(cartDetails);
Cart screenshot:
Request Screenshot:
Hope it helps,
Thanks,
Murthy
Murthy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2022 08:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2022 09:06 AM
I've tried something similar to your scenario which added me two different catalogs into cart and one request
for (i = 0; i < 2; i++) {
var cart = new sn_sc.CartJS();
if(i==0)
{
var item =
{
'sysparm_id': 'd66518691ba10910558d639bbc4bcbc0',
'sysparm_quantity': '1',
'variables':{
' details1': 'at_and_t_mobility',
}};
}
else
{
var item =
{
'sysparm_id': 'a9b30d601b7a3410558d639bbc4bcb3f',
'sysparm_quantity': '1',
'variables':{
'testing': 'at_a',
}};
}
var cartDetails = cart.addToCart(item);
gs.info(JSON.stringify(cartDetails));
}
var cartDetails = cart.orderNow(item);
gs.info(cartDetails);
Cart screenshot:
Request Screenshot:
Hope it helps,
Thanks,
Murthy
Murthy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2022 09:32 AM
Thanks this worked preictally with one minor tweak. I had to use cart.submitOrder(item). I'm guessing it has something to do with having two step checkout turned on.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2023 06:14 AM - edited 05-05-2023 12:50 PM
Hi guys!
Thank you so much @Murthy Ch I got the solution because of you! I was also having problems using CartJS, my solution was like this:
var id_rp = gs.getProperty('prop.id_rercod_producer');
for (var i = 0; i < requests.length; i++) {
var catalog_item = new sn_sc.CatItem(id_rp);
var values = {
'number_request': requests[id],
'variables': {
'number_request': requests[i],
'review_req': true,
'json_req_fields': json
}
};
var targetRecordDetails = catalogItem.submitProducer(values);
}