- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2016 09:54 AM
Hello,
I am on Helsinki Patch 6.
I have a record producer that submits a record to the incident table. I have 3 fields on the record producer, Category, Subcategory, and Subcategory Type, that are all dependent on each other. Subcategory Type should only populate for certain subcategories I have created several catalog client scripts to control this functionality. These client scripts work without issue when testing them on my Admin account, however when I switch over to an ITIL or ESS user, the scripts do not function correctly.
Example:
Admin User | Non-Admin User (ESS) |
---|---|
![]() | ![]() |
I have the following Catalog Client Scripts active:
- Clear Subcategory onLoad
function onLoad (control, oldValue, newValue, isLoading) {
g_form.clearOptions('subcategory');
}
-Category / Subcategory Dependency (onChange)
function onChange(control, oldValue, newValue, isLoading) {
if(newValue == oldValue){
return;
}
//remove all items from subcategory drop down to start
g_form.clearOptions('subcategory');
//build a new list of dependent options
var gp = new GlideRecord('sys_choice');
gp.addQuery('dependent_value', newValue);
gp.addQuery('element', 'subcategory');
gp.addQuery('inactive', 'false');
gp.orderBy('label'); //Order subcategory by the label value
gp.query();
while(gp.next()){
g_form.addOption('subcategory', gp.value, gp.label);
}
}
-Clear Subcategory Type onLoad
function onLoad (control, oldValue, newValue, isLoading) {
g_form.clearOptions('u_subcategory_type');
}
- Subcategory / Subcategory Type Dependancy
function onChange(control, oldValue, newValue, isLoading) {
if(newValue == oldValue){
return;
}
//remove all items from subcategory drop down to start
//g_form.clearOptions('u_subcategory_type');
//build a new list of dependent options
var gp = new GlideRecord('sys_choice');
gp.addQuery('dependent_value', newValue);
gp.addQuery('element', 'u_subcategory_type');
gp.orderBy('label'); //Order subcategory by the label value
gp.query();
while(gp.next()){
g_form.addOption('u_subcategory_type', gp.value, gp.label);
}
}
Everything works 100% correct and as intended on admin role accounts but nothing else and I've been having the toughest time trying to figure out why. Has anyone seen anything like this or can shed some light on where to look to try and resolve it?
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2016 10:35 AM
Usually when I run into problems like this, it's related to the ACLs on the tables that you're linking to. I would check and make sure that the non-admin user has read access on the fields that are being accessed by the client script. Hopefully granting read access will clear up the issue.
EDIT: I've also found that some judicious use of gr.getRowCount() can be very useful in cases like this to make sure that you're actually getting the number of records (or any records at all) from your GlideRecord queries, without having to try to delve into actual GlideRecord objects that might or might not exist.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2016 10:35 AM
Usually when I run into problems like this, it's related to the ACLs on the tables that you're linking to. I would check and make sure that the non-admin user has read access on the fields that are being accessed by the client script. Hopefully granting read access will clear up the issue.
EDIT: I've also found that some judicious use of gr.getRowCount() can be very useful in cases like this to make sure that you're actually getting the number of records (or any records at all) from your GlideRecord queries, without having to try to delve into actual GlideRecord objects that might or might not exist.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2016 11:20 AM
Thank you, Benjamin.
I have checked the fields for Category, Subcategory, and Subcategory type and none of them had any read ACLs associated with them. I created read ACLs with no-roles and the issue is still happening.
Edit: After looking closer into the sys_choice ACLs "value" did not have a read ACL associated with it. The entire sys_choice table had the read ACL enabled, but it appears that for a Client Script each field needs a read ACL or the script will not work.
So to recap, adding adding sys_choice.value a non-role read ACL resolved this issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2016 11:42 AM
Have you checked the table ACLs also? Since you're looking at the sys_choice table for that, I could imagine there may be table ACLs getting in the way.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2016 11:57 AM
Use callback when you are doing glideRecord queries on the client side. Not sure if this will work, but try this. Change your onChnage client script to these
function onChange(control, oldValue, newValue, isLoading) {
if(newValue == oldValue){
return;
}
//remove all items from subcategory drop down to start
g_form.clearOptions('subcategory');
//build a new list of dependent options
var gp = new GlideRecord('sys_choice');
gp.addQuery('dependent_value', newValue);
gp.addQuery('element', 'subcategory');
gp.addQuery('inactive', 'false');
gp.orderBy('label'); //Order subcategory by the label value
gp.query(CallBack);
function CallBack(gp){
while(gp.next()){
g_form.addOption('subcategory', gp.value, gp.label);
}
}
}
function onChange(control, oldValue, newValue, isLoading) {
if(newValue == oldValue){
return;
}
//remove all items from subcategory drop down to start
//g_form.clearOptions('u_subcategory_type');
//build a new list of dependent options
var gp = new GlideRecord('sys_choice');
gp.addQuery('dependent_value', newValue);
gp.addQuery('element', 'u_subcategory_type');
gp.orderBy('label'); //Order subcategory by the label value
gp.query(CallBack);
function CallBack(gp){
while(gp.next()){
g_form.addOption('u_subcategory_type', gp.value, gp.label);
}
}
}