Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How do we find out the record, given the sys_id?

upasanamahanta
Mega Contributor

Given a sys_id, how do we find to which record the sys_id belongs to?

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

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;


      }


}


View solution in original post

17 REPLIES 17

arobertson
Tera Guru

I would have thought you could look on the task table and create a filter to search for sys_id in question?


Community Alums
Not applicable

Out on share there is an app called OneSearch that searches (among other items) sys_id. Perhaps that is what you are looking for?


Chuck Tomasi
Tera Patron

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;


      }


}


yes, Chuck. Even I was thinking about to write this script. Thank you