Finding A Sys_id Across The System

Sometimes when writing your scripts, a sys_id is logged and you have no idea where it comes from. Or you see a sys_id referenced somewhere but not sure what it is. It’s happened a few times before to me and taken a bit of digging and guess work to figure out where to eventually find it. So I decided to write a script to find it instead.

findSysID('your mysterious sysid here');
function findSysID(id) {
var gr = new GlideRecord('sys_db_object');
gr.addEncodedQuery('super_class=NULL^nameNOT LIKEts_c_^nameNOT LIKEsysx_^nameNOT LIKEv_');
var searchTable, name;
while ( {
name = + '';
searchTable = new GlideRecord(name);
if (searchTable.isValid()) {
searchTable.addQuery('sys_id', id);

if (searchTable.hasNext()) {
gs.print('Found on table: ' + name);

All this script does is finds all the base tables within the system (it excludes text search tables and virtual tables), and does a query on them looking for that sys_id. If it finds it, it prints out what table it found it on.

Just be wary that sys_ids aren’t necessarily unique across the system, just on the individual tables so you might find 2 or 3 results returning. But still, it’s a good indication of where to look

1 Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.