"Cart has items restricted by user criteria: no thrown error" when trying to order through sn_sc.CartJS orderNow method
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2020 09:50 AM
We have an Inbound Email Action for New User Onboarding that reads the content of an email notification from our HR Onboarding system. It has been using sn_sc.CartJS.orderNow all along to submit the order for the single user. While working on development of a new process I discovered that the orderNow method is throwing an exception "Cart has items restricted by user criteria: no thrown error" Below is a snippet of code from the ordering process within the Inbound Email Action.
var variables = JSON.stringify(newUser);
//create a cart
var cart = new sn_sc.CartJS('cart_fb167863dbe953007151e536ca961935');
var request =
{
'sysparm_id': 'fb167863dbe953007151e536ca961935',
'sysparm_quantity': '1',
'variables': newUser
};
gs.info("request: " + JSON.stringify(request) );
try{
var cartDetails = cart.orderNow(request);
gs.info('cartDetails: ' + JSON.stringify(cartDetails));
}catch(err)
{
gs.error(err.message);
gs.error(err);
}
I have already removed any User Criteria associated with the Catalog item in question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2020 11:35 AM
use cart api in your inbound action like below
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2020 11:46 AM
It is already pretty similar to the code here: https://docs.servicenow.com/bundle/madrid-application-development/page/app-store/dev_portal/API_refe...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2020 01:13 PM
I think we're seeing the same issue, and it seems to have started as of Orlando Patch 3.
Our temporary workaround has been to create a new User Criteria record called 'Anybody' and leave everything in it blank (no roles, no users, etc). We then added that criteria under 'Available for' on the catalog item in question.
We're still trying understand this issue better, but this does allow us to make the API call and generate the requested item records.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2020 01:40 PM