- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2015 09:38 PM
Is there a way to identify the record in an instance just based on the sys_id, without knowing the table name?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2015 09:21 AM
I just wrote and tested the following scheduled job which will look for a table that has a record with a particular sys_id. I exclude some tables from the search.
do_find_sys_id('e836b3e5b0be02008cbdd6bd573aaccf');
function do_find_sys_id(sys_id) {
var job_name = 'Find sys_id';
gs.log('========== Begin ' + job_name + ' for ' + sys_id + ' ==========');
var table_name = [];
var table = new GlideRecord('sys_db_object');
table.orderBy('name');
table.query();
while (table.next()) {
if ((table.name.toString() != '') &&
(table.name.toString().substring(0,2) != 'ts') &&
(table.name.toString().substring(0,2) != 'v_') &&
(table.name.toString().substring(0,3) != 'dis') &&
(table.name.toString().substring(0,3) != 'dsc') &&
(table.name.toString().substring(0,3) != 'ecc') &&
(table.name.toString().substring(0,3) != 'ha_') &&
(table.name.toString().substring(0,3) != 'wf_') &&
(table.name.toString().substring(0,3) != 'win') &&
(table.name.toString().substring(0,4) != 'sysx')) {
//gs.log('Processing table ' + table.name + ' (' + table.name.toString().substring(0,3) + ').');
var object = new GlideRecord(table.name);
if (object.get(sys_id)) {
table_name.push(table.name.toString());
}
}
}
if (table_name) {
gs.log('Found ' + sys_id + ' in ' + table_name.join(', ') + '. Use nav_to.do?uri=' + table_name[0] + '.do?sys_id=' + sys_id);
}
else {
gs.log('Did not find sys_id ' + sys_id + '.');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2015 10:21 PM
HI Rakesh,
This post indicates the answer is no:
How can I tell what item a sys_id came from?
Best Regards
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2015 09:21 AM
I just wrote and tested the following scheduled job which will look for a table that has a record with a particular sys_id. I exclude some tables from the search.
do_find_sys_id('e836b3e5b0be02008cbdd6bd573aaccf');
function do_find_sys_id(sys_id) {
var job_name = 'Find sys_id';
gs.log('========== Begin ' + job_name + ' for ' + sys_id + ' ==========');
var table_name = [];
var table = new GlideRecord('sys_db_object');
table.orderBy('name');
table.query();
while (table.next()) {
if ((table.name.toString() != '') &&
(table.name.toString().substring(0,2) != 'ts') &&
(table.name.toString().substring(0,2) != 'v_') &&
(table.name.toString().substring(0,3) != 'dis') &&
(table.name.toString().substring(0,3) != 'dsc') &&
(table.name.toString().substring(0,3) != 'ecc') &&
(table.name.toString().substring(0,3) != 'ha_') &&
(table.name.toString().substring(0,3) != 'wf_') &&
(table.name.toString().substring(0,3) != 'win') &&
(table.name.toString().substring(0,4) != 'sysx')) {
//gs.log('Processing table ' + table.name + ' (' + table.name.toString().substring(0,3) + ').');
var object = new GlideRecord(table.name);
if (object.get(sys_id)) {
table_name.push(table.name.toString());
}
}
}
if (table_name) {
gs.log('Found ' + sys_id + ' in ' + table_name.join(', ') + '. Use nav_to.do?uri=' + table_name[0] + '.do?sys_id=' + sys_id);
}
else {
gs.log('Did not find sys_id ' + sys_id + '.');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2020 09:53 AM
This script still works, today (05/2020); thank you. Can be run from "System Definition - Scripts - Background". Made a small code style update:
function do_find_sys_id(sys_id) {
gs.log('Begin search for sys_id: ' + sys_id);
var table_name = [];
var table = new GlideRecord('sys_db_object');
table.orderBy('name');
table.query();
while (table.next()) {
var tableName = table.name.toString();
//If the table is not one that we wish to Exclude...
if ( (tableName != '')
&& (! tableName.startsWith('dis'))
&& (! tableName.startsWith('dsc'))
&& (! tableName.startsWith('ecc'))
&& (! tableName.startsWith('ha_'))
&& (! tableName.startsWith('sh$'))
&& (! tableName.startsWith('sysx'))
&& (! tableName.startsWith('ts'))
&& (! tableName.startsWith('v_'))
&& (! tableName.startsWith('wf_'))
&& (! tableName.startsWith('win'))
&& (! tableName.startsWith('pa_scores'))
&& (tableName != 'cert_instance')
&& (tableName != 'u_market_assignment_routing') )
{
gs.log('Processing table: ' + table.name); //Used for debugging only.
var object = new GlideRecord(table.name);
if (object.get(sys_id)) {
table_name.push(table.name.toString());
}
}
}
if (table_name) {
gs.log('Found sys_id ' + sys_id + ' in tables: ' + table_name.join(', '));
}
else {
gs.log('Did not find sys_id ' + sys_id + '.');
}
}
do_find_sys_id("6b18818513ae36001ca459812244b0b7"); //Your sys_id here

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2020 09:58 AM
This Geoffcox script still works, today (05/2020); thank you. Made a small code style update. Can be run from "System Definition - Scripts - Background".
function do_find_sys_id(sys_id) {
gs.log('Begin search for sys_id: ' + sys_id);
var table_name = [];
var table = new GlideRecord('sys_db_object');
table.orderBy('name');
table.query();
while (table.next()) {
var tableName = table.name.toString();
//If the table is not one that we wish to Exclude...
if ( (tableName != '')
&& (! tableName.startsWith('dis'))
&& (! tableName.startsWith('dsc'))
&& (! tableName.startsWith('ecc'))
&& (! tableName.startsWith('ha_'))
&& (! tableName.startsWith('sh$'))
&& (! tableName.startsWith('sysx'))
&& (! tableName.startsWith('ts'))
&& (! tableName.startsWith('v_'))
&& (! tableName.startsWith('wf_'))
&& (! tableName.startsWith('win'))
&& (! tableName.startsWith('pa_scores'))
&& (tableName != 'cert_instance')
&& (tableName != 'u_market_assignment_routing') )
{
gs.log('Processing table: ' + table.name); //Used for debugging only.
var object = new GlideRecord(table.name);
if (object.get(sys_id)) {
table_name.push(table.name.toString());
}
}
}
if (table_name) {
gs.log('Found sys_id ' + sys_id + ' in tables: ' + table_name.join(', '));
}
else {
gs.log('Did not find sys_id ' + sys_id + '.');
}
}
do_find_sys_id("6b18818513ae36001ca459812244b0b7"); //Your sys_id here