- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 10:05 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 10:19 AM
Hi @Lidi2115 ,
You can use the SN Utils to fetch the record through sys_id.
You can add the extension to your browser
use /<your_sys_id>
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.**
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 10:19 AM
Hi @Lidi2115 ,
You can use the SN Utils to fetch the record through sys_id.
You can add the extension to your browser
use /<your_sys_id>
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.**
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 10:37 AM
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