Create global records from scoped application script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2017 07:30 AM
I am creating a scoped application. Within the application, I'm creating a workflow to sync products from an external source. This sync process will create sc_cat_items in ServiceNow. However, when executing the following code:
var catItems = new GlideRecord('sc_cat_item');
catItems.initialize();
catItems.name = 'bogus';
catItems.active = 'true';
catItems.insert();
I get the following error:
"Create operation against 'sc_cat_item' from scope 'x_moda_myapplication_ca' has been refused due to the table's cross-scope access policy"
The only way to successfully create the record is to go to the sc_cat_item table and edit the Application Access so ALL applications 'Can Create'.
However, this seems like a bad practice. Is there a way to create a record (like sc_cat_item) from within a script running in a custom application? Or, should I be executing this script in the global space.. somehow? Also.. I tried to modify the 'Cross Scope Privelage' within my application, as shown below, but it did not seem to help.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2017 11:50 AM
Hello Bob,
With the latest release(Geneva onwards) we have OOTB API's for service catalog which would fulfill the above task with out any modification of application access settings. Please refer below link for more info.
Reference: https://developer.servicenow.com/app.do#!/api_doc?v=geneva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2017 05:17 AM
Thank you for the information. It appears that CatItem would meet my needs. However, I can not seem to get it to work. For example, if I attempt to do the following (through 'Scripts - Background'):
var newsysid = CatItem.create(false); // or var newsysid = new CatItem();
gs.info('newsysid'+newsysid);
I get the following error:
Evaluator: org.mozilla.javascript.EcmaError: "CatItem" is not defined.
Can you provide a quick example? Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2017 08:04 AM
Bob,
The syntax for this is :
var catItem = new sn_sc.CatItem();
catItem.setAttributes({"name": "My Catalog Item"});
var catItemSysId = catItem.create();