How to insert sys_choice for scoped application element?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2017 06:16 AM
Hi,
Can someone please suggest how to populate sys_choice for scoped application element.I have written following code:
var setRecord = new GlideRecord("sys_choice");
setRecord.initialize();
setRecord.element = "x_12345_catalyst_bot_name";
setRecord.inactive = "false";
setRecord.label = reqBody.botName;
setRecord.language = "en";
setRecord.name = "incident";
setRecord.value = reqBody.botName;
setRecord.insert();
But data is not listed under choice.It is working in my local env but when I have installed the application on another instance it is not working.I think it is an application access related issue.But I am not getting any idea how to fix it.
Thanks,
Vimal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2017 11:11 AM
I don't get why you would do this via script. Is your app dynamically creating choice list values on incident table?
I would assume that the sys_choice table would not allow writing to it from outside global scope. Maybe you have modified this in your dev instance to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2017 11:19 AM
Hi Daniel,
Thanks for the reply!!
yes, I am trying to create choices dynamically on the incident table.
So if I understand it correctly, We can create dynamic choice from the application scope.
Thanks,
Vimal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2017 09:27 AM
Based on my baseline instance other scopes are not allowed to create entries in sys_choice by scripting:
Trying to add a record via script triggered this message:
Security restricted: Execute operation on API 'GlideRecord.insert' from scope 'DD Test Scoped App' was granted and added to 'DD Test Scoped App' cross scope privileges
Security restricted: Create operation against 'sys_choice' from scope 'x_snc_dd_test_scop' has been refused due to the table's cross-scope access policy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2017 05:21 PM
Has anyone found a workaround for this?
It would be nice to bundle creation of choices into the application install. For example, I have a scoped application that creates CI classes and uses Identification and Reconciliation to populate those classes. I&R requires a Data Source string that is defined in the sys_choice table. But the sys_choice table is global, so a fix script can't add a new data source. At that point, I have to provide a separate update set for the user to load. If they don't do it, the application is broken.
I vaguely remember some tips on bundling demo data with your scoped app. But I'm pretty sure that only applies to data in the same scope.
Any advice?