cart API since Quebec Upgrade

jonmulherin
Giga Expert

Since upgrading from Orlando to Quebec cart.placeOrder() is no longer working in our Inbound Actions.  I've logged a ticket with ServiceNow but I'm wondering if anyone has experienced the same.  I creating a very basic Inbound Action on all three of our instances to test with.  It runs find on production and creates a request but only displays the gs.info string just above cart.placeOrder() on the upgraded sub-prod instances.  No ticket is created and the last gs.info never appears in the log.  Here is the test inbound action:

gs.include('validators');
gs.info('Junk - In Junk');
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('29cc96fa4fb18a80acbe01b28110c779');
cart.setVariable(item, 'request_for', 'ac6d82eadbab4050927622e648961931');
cart.setVariable(item, 'growth_center_commercial_team', '83a843fe4f2006005238dd2f0310c7bc');
cart.setVariable(item, 'item', '2ebce4b34fb6b600c09001b28110c76b');
cart.setVariable(item, 'business_justification', 'aaa');
gs.info('Junk - Placing Order');
var rc = cart.placeOrder();
gs.info('Junk - rc.number = ' + rc.number);

1 ACCEPTED SOLUTION

jonmulherin
Giga Expert

We did not upgrade to Paris.  We've upgraded from Orlando to Quebec.

Received a response from SN Support.

From 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.

Add the "Available for" -- "Any User". OR
If you don't want to select "Any User" from the pre populated list in the "Available For", then you can click on the "New" (Instead of Edit) and create a custom list of the user criteria to whom you want to give access to the catalog item. OR
You can click on Edit and add user criteria that match the current user who is placing the order.

Please note that emails from external users that have no User[sys_user] record on the system (e.g. @gmail.com where there is no User record with Email=@gmail.com) are processed as the instance's internal guest user. For this workaround to work for the guest user you need to have a User Criteria that has no restrictions, such as the out-of-box Any User User Criteria. Any Catalog Items that can be ordered by external (i.e guest) users need to be under Available For Catalog Items on that unrestricted User Criteria.

View solution in original post

7 REPLIES 7

Prasad Pagar
Mega Sage

Hello,

I dont think there is impact of cart API in Quebec. Its not depreciated or changed from Paris to Quebec as I can see in below official document.

https://docs.servicenow.com/bundle/quebec-application-development/page/script/server-scripting/reference/r_ServiceCatalogScriptAPI.html

Good to know what HI team says, No issues with your code until field names and mapping is correct.

Please mark my answer correct/helpful if applicable.

Thank you
Prasad

jonmulherin
Giga Expert

We did not upgrade to Paris.  We've upgraded from Orlando to Quebec.

Received a response from SN Support.

From 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.

Add the "Available for" -- "Any User". OR
If you don't want to select "Any User" from the pre populated list in the "Available For", then you can click on the "New" (Instead of Edit) and create a custom list of the user criteria to whom you want to give access to the catalog item. OR
You can click on Edit and add user criteria that match the current user who is placing the order.

Please note that emails from external users that have no User[sys_user] record on the system (e.g. @gmail.com where there is no User record with Email=@gmail.com) are processed as the instance's internal guest user. For this workaround to work for the guest user you need to have a User Criteria that has no restrictions, such as the out-of-box Any User User Criteria. Any Catalog Items that can be ordered by external (i.e guest) users need to be under Available For Catalog Items on that unrestricted User Criteria.

Hi,

Thank you for letting me know. Its useful information. Paris I just took for example but what I wanted to confirm was that its available in Quebec too.

@Ankur Bawiskar @Aman Singh @Anil Lande - This is just FYI. Good one to know if anyone else ask same question. Many of them going to update to Quebec release so it may come.

Thank you
Prasad

Thank you Prasadjonmulherin.