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

Hi Vicki,

In your message, you say Order Guide. Please add the User Criteria to the catalog items that the order guide contains.

Let me know how that works.

Thanks,

Cody

 

 

Hi Cody,

 

I have tried the same added the user criteria but its still not working for me, @Ankur Bawiskar  @Pradeep Sharma  @Chuck Tomasi  can you guys please help me with this.

Any help will be appricaiated.

 

Thanks

Hi Cody! Hope all is well. I ran into this same issue and your post here has helped me figure this out! Glad to see a familiar face in the community. 

- Jalen Dixon

codycotulla
Tera Guru

Hi Rishi, 

Please provide a more details on what isn't working.

Thanks,

Cody

Hi Cody,

I'm having a similar problem with a script I have that's basically identical to yours, ordering an item and filling in the variables; was working in New York but now fails in Paris; I'm also getting a "did not create or update sc_req_item using current" error and I can see that the Inbound Action script is running as there is something written to the log that confirms that. I added the "Any User" User Criteria to the catalog item but that did not change the result (still getting error).

I tried to open a ticket with support but they said that custom scripts are outside the scope of support... 

Any idea what else could be causing this?