sys_id

Lidi2115
Tera Contributor

Hi,

How to identify a component through sys id servicenow?

I have a sys_id and I would like to know if I can identify which component it belongs to, if it is a record producer, or order guide, or some other.

 

This one: 
sys_id=c60c8a131be8391065e476295b4bcb38



1 ACCEPTED SOLUTION

Hemant Goldar
Mega Sage
Mega Sage

Hi @Lidi2115 ,

You can use the SN Utils to fetch the record through sys_id.
You can add the extension to your browser 

HemantGoldar_0-1692724483574.png

use /<your_sys_id>

HemantGoldar_1-1692724617546.png

 

 

I hope this helps!

 

Regards,

Hemant 

**Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.**

View solution in original post

2 REPLIES 2

Hemant Goldar
Mega Sage
Mega Sage

Hi @Lidi2115 ,

You can use the SN Utils to fetch the record through sys_id.
You can add the extension to your browser 

HemantGoldar_0-1692724483574.png

use /<your_sys_id>

HemantGoldar_1-1692724617546.png

 

 

I hope this helps!

 

Regards,

Hemant 

**Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.**

Tai Vu
Kilo Patron
Kilo Patron

Hey @Lidi2115 

 

You might want to give this script a whirl! 🤖

 

function findSysID(sysId) {
    var tbls = ['sys_metadata', 'task', 'cmdb_ci', 'sys_user'];
    var rtrn;
    var i = 0;
    while (tbls[i]) {
        rtrn = findClass(tbls[i], sysId);
        i++;

        if (rtrn) {
            gs.print("###" + rtrn + "###")
            return
        };
    }

    var tblsGr = new GlideRecord("sys_db_object");
    tblsGr.addEncodedQuery("super_class=NULL^sys_update_nameISNOTEMPTY^nameNOT LIKE00^nameNOT LIKE$^nameNOT INsys_metadata,task,cmdb_ci,sys_user,cmdb_ire_partial_payloads_index^scriptable_table=false^ORscriptable_tableISEMPTY");
    tblsGr.query();
    while (tblsGr.next()) {
        var tableName = tblsGr.getValue('name');
        var forbiddenPrefixes = ['ts_', 'sysx_', 'v_', 'sys_rollback_', 'pa_'];
        var hasForbiddenPrefix = forbiddenPrefixes.some(function(forbiddenPrefix) {
            return tableName.startsWith(forbiddenPrefix);
        });
        if (hasForbiddenPrefix) {
            continue;
        }
        rtrn = findClass(tableName, sysId);
        if (rtrn) {
            gs.print("###" + rtrn + "###")
            return
        };
    }
    function findClass(t, sysId) {
        try {
            var s = new GlideRecord(t);
            s.addQuery('sys_id', sysId);
            // Order is important: setWorkflow must be before setLimit.
            s.setWorkflow(false);
            s.setLimit(1);
            s.queryNoDomain();
            s.query();
            if (s.hasNext()) {
                s.next();
                return s.getRecordClassName() + "^" 
                + s.getClassDisplayValue() + " - " 
                + s.getDisplayValue() ;
            }
        } catch(err) {  }
        return false;
    }
}

var sysID = '...'; //put the sys_id to find
findSysID(sysID);

 

Cheers

Tai Vu