- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2016 07:50 AM
Given a sys_id, how do we find to which record the sys_id belongs to?
Solved! Go to Solution.
- Labels:
-
Upgrades and Patches

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2016 08:04 AM
You COULD write a script that goes through sys_db_object and checks each table to see if it can find the record. With over 2,000 tables in a default Helsinki instance, this could take a while. The *untested* script might look something like this:
var mySysId = 'xxxxxxxxxxxxxxxxxxxxx'; // put in your sys_id here
var table = new GlideRecord('sys_db_object');
table.query();
while (table.next()) {
var gr = new GlideRecord(table.getValue('name'));
if (gr.get(mySysId)) {
gs.log('it looks like it came from ' + gr.getValue('label'));
break;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2023 01:59 AM
Hey Mike,
the code has dependencies to other script includes from the DevTools app.
You can find installation instructions here:
https://www.wildgrube.com/servicenow-devtools
Let me know if it works for you!
Cheers
Sascha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2023 03:25 AM
I prefer something I can put into a Fix Script rather than install tools

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2023 03:37 AM
In that case I can't convince you of installing CodeSanity either:
https://www.wildgrube.com/servicenow-codesanity
1. Its yet another tool
2. It contains Instance Scan checks - one of them sanctioning fix scripts
😄