Why I am getting "GlideGuid is not allowed in scoped applications" error while executing the Scripted REST API?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2020 08:55 AM
Hi
I am getting following error error while calling the Scripted REST API from REST API Explorer,
GlideGuid is not allowed in scoped applications
please find the code snippet below which is used inside scripted REST API.
var data = request.body.data;
var user_name = data.user_name;
var action_type = data.action_type;
var location = data.location;
// finding sys id of given user
var grUser = new GlideRecord('sys_user');
grUser.addQuery('name',user_name);
grUser.query();
if(grUser.next()){
user_id = grUser.getValue('sys_id');
}
// finding sys id of provided location
var grloc = new GlideRecord('cmn_location');
grloc.addQuery('name',location);
grloc.query();
if(grloc.next()){
location_id = grloc.getValue('sys_id');
}
// Creating Request, Requested Item and setting variables
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId); //calling the cart API
var item = cart.addItem('b344************9b68a'); //Used proper sys_id
cart.setVariable(item, 'select_action', action_type);
cart.setVariable(item, 'location', location_id);
cart.setVariable(item, 'select_the_user_to_add_or_remove_vip_access', user_id);
var req = cart.placeOrder();
Regards,
Phalguna

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2020 09:03 AM
try using gs.generateGUID() instead of GlideGuid.generate(null);
or try
var cart = new sn_sc.CartJS();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2020 09:07 AM
gs.generateGUID() is working ,Thank you Mike

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2020 09:24 AM
Please mark answer correct to close out the thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2020 09:46 AM
Hi,
you can use below code
it would work for both global and custom scope
var cart = new sn_sc.CartJS();
var item =
{
'sysparm_id': '0d08837237153000158bbfc8bcbe5d02',
'sysparm_quantity': '1',
'variables':{
'user': 'Abel Tuter',
'location': 'Texas',
'created_by': 'abel.tuter',
'action_type': 'hello'
}};
var cartDetails = cart.addToCart(item);
gs.info(cartDetails);
var checkoutInfo = cart.checkoutCart();
gs.info(checkoutInfo);
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader