
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2020 03:28 PM
Hi,
Question: Is there a system property or something that prevents the Guest user from being able to create a request using the Cart API?
Situation
After upgrading from NY to Paris, I find that when Guest is the active user and I try to use the Cart API to create a request. I get a failure message.
com.glideapp.servicecatalog.exceptions.CartException: Your cart has item(s) no longer available. Please remove XXXXRequestTitleXXXXX from cart to continue with the checkout.
If I add a User Criteria record allowing any user (no restrictions) to the Available For related list, then the call succeeds.
I found the problem when inbound email actions failed after upgrading. Then I created an ATF test using script taken from the Inbound email action:
Testing Done
I created an ATF test that calls the API using the same code that is in the inbound email action.
(function(outputs, steps, stepResult, assertEqual) {
// add test script here
try {
var message = "";
// set the "success" variable to false if there is an expected result in the script
var success = true;
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId); //calling the cart API
//var cart = new Cart(); //calling the cart API
var item = cart.addItem('21870631db98ff00660658b8dc96199b'); //sys_id of the catalog item I want to fire
cart.setVariable(item, 'mm_reason_for_request', 'Unknown - Email');
cart.setVariable(item, 'sc_requested_for', gs.getUserID());
cart.setVariable(item, 'sc_requested_for_userid', gs.getUserName());
cart.setVariable(item, 'sc_requested_for_email', gs.getUser().getRecord().getDisplayValue('email'));
cart.setVariable(item, 'sc_requested_for_manager', gs.getUser().getManagerID());
var rc = cart.placeOrder(); //this launches the catalog item, and creates a request object. rc = the request object
message += "\nCart rc: " + rc.sys_id;
if (success) {
stepResult.setOutputMessage('Success!\n' + message);
return true;
} else {
stepResult.setOutputMessage('Failure!\n' + message);
return false;
}
} catch (e) {
stepResult.setOutputMessage('Failure!\n' + e + message);
return false;
}
})(outputs, steps, stepResult, assertEqual);
Test Results
I find that the test succeeds in the following cases:
- Impersonate an existing user with a role.
- Create a user with no roles.
- Impersonate the Guest User and add a User Criteria to the Available For
Fails in this case;
- Impersonate the Guest User (no user Criteria on the catalog item)
Let me know if you have any questions.
Any help would be appreciated,
Thanks,
Cody
Solved! Go to Solution.
- 6,364 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2020 09:47 AM
I opened a Hi ticket for this, and they confirmed that with Paris if you want to allow the Guest user (an unauthenticated user) to use the Cart api to create a catalog request, you need to make the catalog item available for any user by adding a User Criteria record with no-restrictions.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2020 09:47 AM
I opened a Hi ticket for this, and they confirmed that with Paris if you want to allow the Guest user (an unauthenticated user) to use the Cart api to create a catalog request, you need to make the catalog item available for any user by adding a User Criteria record with no-restrictions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2020 07:56 AM
I tried this, but unfortunately it is not working for me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2020 09:04 AM
Cody - this helped solve my problem, thank you!
For those that might not know, there should be an "Any User" criteria group you can add to the Catalog Item.
As an added word of caution, when I edited the "Available For" to include "Any User", the next item ordered triggered a backlog of requested items. I did this in our dev instance, because I was concerned it would send out a boatload of backlogged emails. Considering the outbox had 97 send-ready messages, I'm glad I did.
Many ServiceNow clients may not have the luxury to do this - our instance doesn't send out a lot of emails, so I temporarily put our Production instance in "debug" mode and sent all the messages to my email address. If anyone has a better way of doing this - please let me know. I considered temporarily disabling email, and deleting them in the "send-ready" state.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2021 11:17 PM
Hi
Can you guys please help me out, I am facing the same issue I have added the user Criteria as mentioned in my order guide but still I am getting the error.
I need to resolve this issue on Priority bases.
Any Help will be Appreciated!
Thanks