How to find a Table Name using sys_id?

harshayer
Tera Contributor

I have a sys_id value of a table and I want to find out the table associated with that sys_id. Is there any way i can find out the table or record name using the sys_id?

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Sandeep,



Sample script here. Please adjust it as per your need.


var gr = new GlideRecord('sys_db_object');


gr.addQuery('sys_id','YOURSYSID HERE');


gr.query();


while(gr.next())


  {


  gs.addInfoMessage(gr.name); //This will give you table name


}


Business Rules - ServiceNow Wiki


Business Rules Best Practices - ServiceNow Wiki


You can fire it from Background script for testing purpose. More info here.


Background Scripts — ServiceNow Elite  


View solution in original post

17 REPLIES 17

What Sandeep is asking for is, here's a sys_id 03973320c0a801020075d86be149dcbb



What table does the associated record go with? Is it business rule record from sys_script? Is it an incident record from incident? Who knows?


Got you. Thanks chuck for the update


@Sandeep, I am not sure if the below app will address your question or not, but you can give it a try.


http://www.servicenowguru.com/system-definition/global-script-config-search/


There is a reference field called profile on a form.

 

I get a sys_id of profile. Now I want to find the table name for the profile.

 

I can not pass that to "sys_db_object" because it's the sys_id of the record and not the actual reference table where that record exists.

 

That's why Chuck is right in saying it will not work.

Thanks Pradeep for the script. I was able to retrieve the records based on the sys_id.


You mean my script is working fine now 🙂