"Cart has items restricted by user criteria: no thrown error" when trying to order through sn_sc.CartJS orderNow method

aspeed
Giga Contributor

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.

5 REPLIES 5

sachin_namjoshi
Kilo Patron
Kilo Patron

use cart api in your inbound action like below

 

https://docs.servicenow.com/bundle/madrid-application-development/page/app-store/dev_portal/API_refe...

 

Regards,

Sachin

Chris Vuocolo
Tera Contributor

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.

Orlando Patch 3 was where we witnessed the issue as well. I was able to solve the issue after submitting a Case in HI both without any User Criteria and then with it restored later on. The issue was for us was that the email address was sending to SN did not have an account in the User table. Where were you calling the Scoped Cart API? Ours was in an inbound email action.