Get display value from sys_id only

adrianps
Kilo Expert

Hoping this is a simple no / yest+howto question.

I've got a sys_id, but I don't know the table from which it belongs.

Is it possible, armed only with a sys_id to work out it's table and display value?

Cheers,

Adrian

(I'll update if I find an answer first...)

EDIT1: One option is to query the sys_audit table on the Document Key field.  If an audit record exists, then the table name can be retrieved, thereby providing enough info to connect using the GlideRecord API.

1 ACCEPTED SOLUTION

Hi Adrian,

You can directly query the sys_audit table also, considering this is a one time run just to find out out the associated table name. In his blog (mentioned in my last response) Jim actually did query all the possible tables to find out the best possible outcome. So from your solution perspective that should be able to give you the result which you are looking for.

 

Hope this helps. Please mark the answer Correct/Helpful based on the impact.

Regards,

Amlan

View solution in original post

3 REPLIES 3

amlanpal
Kilo Sage

Hi Adrian,

 

 

If you are looking for the record using the sysID, you may look at this useful blog:

Useful Background Script - Find a record by its sys_id

 

If you are certain that the sysID is of a table, then you may have to query the sys_db_table following the code snippet:

var gr = new GlideRecord('sys_db_object');
gr.addQuery('sys_id','put your sysID'); 
gr.query();
if(gr.next()){
   gs.log(gr.name); //This will give you table name
}

 

Hope this helps. Please mark the answer Correct/Helpful based on the impact.

Regards,

Amlan

Thanks for the reply Amlan.

Looking at the link you provided - I can see how this simple question can be come quite complex.  I'm going to continue with using my method of querying the sys_audit table (but put a limit on the number of records to return).  For my purposes, I can tolerate the possibility of a documentkey not being found.

Cheers,

Adrian

Hi Adrian,

You can directly query the sys_audit table also, considering this is a one time run just to find out out the associated table name. In his blog (mentioned in my last response) Jim actually did query all the possible tables to find out the best possible outcome. So from your solution perspective that should be able to give you the result which you are looking for.

 

Hope this helps. Please mark the answer Correct/Helpful based on the impact.

Regards,

Amlan