Issue with Accessing Global Tables in Scoped Application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2025 09:23 PM
Hello,
I'm working on a scoped application in ServiceNow and am encountering an issue when trying to access global tables, specifically when the user selects a source table (e.g., Incident). My goal is to use a Script Include to dynamically populate a reference field with values based on a table that may reside in the global scope.
Here is the script include:
var getSourceField = Class.create();
getSourceField.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
setValue: function() {
var tableName = current.source_table;
var tableInfo = [];
var allFields = [];
gs.info("sorce table name is " + tableName);
var gr = new GlideRecord('sys_db_object');
gr.addQuery('name', tableName);
gr.query();
if (gr.next()) {
tableInfo.push(gr.name);
var superClass = gr.super_class;
if (superClass) {
gs.info('superclass found : ' + superClass);
tableInfo.push(superClass.name);
gs.info('superclass found : ' + superClass.name);
} else {
gs.info('No superclass found for table: ' + tableName);
}
gs.info('Considering tables: ' + tableInfo.join(', '));
for (var i = 0; i < tableInfo.length; i++) {
var currentTableName = tableInfo[i];
var grDic = new GlideRecord('sys_dictionary');
grDic.addQuery('name', currentTableName);
grDic.query();
while (grDic.next()) {
var fieldName = grDic.getValue('sys_id');
allFields.push(fieldName);
}
}
gs.info('All fields from source table and superclass: ' + allFields.join(', '));
} else {
gs.info('Table ' + tableName + ' not found in sys_db_object.');
}
return 'sys_idIN' + allFields.toString();
},
type: 'getSourceField'
});
Unable to See Global Tables in Referenced Table Field—Only Scoped Tables Are Visible
Problem:
Despite configuring the "cross-scope privileges" and ensuring that the Script Include is properly called, I’m unable to access or filter global tables (such as Incident) from within my scoped application. This is preventing me from applying filters or selecting reference tables in the dynamic reference qualifier when I attempt to populate reference fields.
What I’ve Tried:
- I've set up the necessary cross-scope privileges for the Script Include to be callable.
- I’m using a dynamic reference qualifier to populate the reference field based on the selected source table.
- Even after allowing cross-scope access, the global tables aren't showing up in the reference field’s list, and no filters are being applied as expected.
Question:
How can I access and filter global tables from within a scoped application when using a dynamic reference qualifier in a Script Include? Are there additional configurations required for this kind of access, or is there a different approach I should be considering?
Any guidance would be greatly appreciated!
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2025 10:17 PM
Hi @nehaaress ,
Your table should have configured like below.
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------