logo

NJP

Find a sys_id anywhere within ServiceNow

Import · Mar 09, 2020 · article

There's been a few of these scripts floating around, but this one is nice and fast... simply pop in the sys_id you need to track down and run this in a background script.

var findSysID = 'f12ca184735123002728660c4cf6a7ef';

var tables = new GlideRecord('sys_db_object');
tables.query();

while(tables.next()){
    try{
         //ignore a bunch of system tables (including indexes, perf analytics, etc)
        if(tables.name.indexOf('ts_')!=0 && tables.name.indexOf('sys_')!=0  && tables.name.indexOf('v_')!=0  && tables.name.indexOf('pa_')!=0   && tables.name.indexOf('sn_')!=0){
            var lookUpID = new GlideRecord(tables.name);
            if(lookUpID.get(findSysID)){gs.info ('FOUND IN ' + tables.name);}
        }
    }catch(e){gs.info('===>Error/n'+e );}
}

As you can see, it ran in just under 20 seconds

image

View original source

https://www.servicenow.com/community/now-platform-articles/find-a-sys-id-anywhere-within-servicenow/ta-p/2305566