ServiceNow Cart API in Scoped Application

Arun Chauhan
Giga Contributor

I have a scoped Application and I want to create the Service Ticket using the Cart API on the Fuji instance. I have following code written in my Script Include inside Scoped Application:

var cartId = gs.generateGUID(null);

var cart = new global.Cart(cartId);

This result in error says:

java.lang.SecurityException: Illegal access to private script include Cart in scope rhino.global being called from scope x_my_app.

The Cart is not available in the private scoped application. I changed the "Accessible from" to "All Application scopes" on Cart Script Include and it started working.

I want to ask, Can I modify my script to make it working without changing the "Accessible from" field on Cart Script Include.

6 REPLIES 6

shouvik
ServiceNow Employee
ServiceNow Employee

If you need Cart APIs for scope, please use supported Scoped APIs instead of changing the scope of a global script include.


That is a hack and will not be supported by Service Now if there are some security issues for cross scoping.



Here is the Scoped API details. We keep updating the APIs based on request. So, if there are APIs which you don't see, please request them and they would be added after review. We keep these updated regularly.



https://developer.servicenow.com/app.do#!/api_doc?v=istanbul&id=server


https://developer.servicenow.com/app.do#!/rest_api_doc?v=istanbul&id=c_ServiceCatalogAPI



We have pushed Cart APIs in Istanbul, and the doc site would soon see the update



Thanks


Shouvik


Hi Shouvik,



Recently we found that the Service Catalog API is not serving our use case. It creates cart using the user authenticating to the REST API which may results in issue if two request comes concurrently for adding item to cart. More details here: ServiceNow Service Catalog API Cart issue