After upgrade from NY to Paris, Using Cart API with Guest User fails if Catalog Item doesn't have User Criteria set

codycotulla
Tera Guru

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

1 ACCEPTED SOLUTION

codycotulla
Tera Guru

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.

View solution in original post

12 REPLIES 12

dik
Kilo Contributor

Hi Tim.

I am facing same issue in Quebec release. Could you please me if you find any solution for this issue.

 

Thanks

Shailja
Kilo Contributor

Hi dik,

 

copy the sys id which you are getting while submitted your order guide, search the item then ass ANY USER user criteria in that ITEm.

RamSagar
Tera Guru

Hi Cody,

We are facing the same issue. but we didn't implemented the user criteria for the catalogs.

so what could be the better fix for the issue and any work around.

Please suggest me on this.