How to find the records using SYS ID

DNC
Tera Contributor

Hi All

 

We have an SYS ID in hand, we want to find the records with that.

is there any process or shortcut to find the records with the SYS ID?

 

Thanks

Nagarjuna

6 REPLIES 6

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @DNC ,

Use below blog script for that

Useful Background Script - Find a record by its sys_id 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

NotNowBoss
Tera Guru

@DNC 

Hello, this should work just change TYPEINSYSIDHERE to your sysID and run it in a background script.
It will give alot of "errors" but scroll all the way to the bottom of the script execution history and you should find something like.

*** Script: https://YOURINSTANCEHERE.service-now.com/TABLE.do?sys_id=YOURSYSIDHERE

You can find classic background scripts at:

https://YOURINSTANCEHERE.service-now.com/now/nav/ui/classic/params/target/sys.scripts.do

 

 

 

gs.log(findAnywhere('TYPEINSYSIDHERE', false));

function findAnywhere(sysIDToFind, getHTML) {
    if (getHTML !== true && getHTML !== 'true') {
        getHTML = false;
    }
    var grCheck;
    var tableName;
    var url = gs.getProperty('glide.servlet.uri');
    var grTable = new GlideRecord('sys_db_object');
    //Make sure we're not looking at a ts (text search) table.
    grTable.addEncodedQuery('sys_update_nameISNOTEMPTY^nameISNOTEMPTY^nameNOT LIKEts_^nameNOT LIKEpa_^nameNOT LIKEsys_rollback');
    grTable.query();
    while (grTable.next()) {
        tableName = grTable.getValue('name');
        grCheck = new GlideRecord(tableName);
        if (grCheck.get(sysIDToFind)) {
            url += tableName + '.do?sys_id=' + sysIDToFind;
            if (getHTML) {
                url = '<a href="' + url + '">' + url + '</a>';
            }
            return url;
        }
    }
}