- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 07:39 AM
Can any one assist to me how to find the record using the sys_id, I dont know the table name.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 07:44 AM
Hi
You can try adding "SN Utils - Tools for ServiceNow" extension in your browser. With this you can get many features out of which sysid search is one.
Or else run background script as mentioned in this link
Mark as correct and helpful if it solved your query.
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2022 02:24 AM
Hi,
you can run the script in background script or fix script and know the record
If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 09:39 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2022 05:56 AM
Hi Ankur
Can you please help me with script, I am unable to find the with script, Please provide me the script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2022 03:00 AM
Hi Dhinesh,
Here is the code with all the comments read the comments when implementing
// Searches for a record using a sys_id
// Replace the "enterYourSys_IdHere" string with the sys_id you are looking for
//
// Optionally add a hyperlink to the record that was found.
// Useful when running the script in the 'Xplore: Developer Toolkit' - https://share.servicenow.com/app.do#/detailV2/9a1be70e13800b000de935528144b04c/overview
// To add a link, set the "addLink" variable to "true"
(function(){
try {
//options
var searchId = "enterYourSys_IdHere"; //the sys_id of the record you are looking for
//searchId = "4715ab62a9fe1981018c3efb96143495"; //example - an OOB demo Incident
//searchId = "08fcd0830a0a0b2600079f56b1adb9ae"; //example - an OOB Schedule, '8-5 weekdays'
//searchId = "62a7bfaf0a0a0a6500c49682bd82376a"; //example - an OOB Business Rule, 'user query'
var addLink = true; //set to "true" to add a link to the record in the output (Xplore)
//initialize
var tableName = "";
var tableLabel = "";
var tableWeWantToSearch = true;
var foundRecord = false;
var message = "";
//loop through all the valid base-class tables (no need to look at any sub-classes)
var table = new GlideRecord("sys_db_object");
table.addEncodedQuery("super_class=NULL");
table.query();
while (table.next()){
//get the table name and label
tableName = (table.getValue("name") + "").toLowerCase();
tableLabel = (table.getValue("label") + "").toLowerCase();
tableWeWantToSearch = true; //assume it is a table we want to search in
//skip views and some other tables that return a lot of probably irrelevant records
//just comment out the line if you want to include the table in the search
if (tableName.indexOf("v_") == 0) tableWeWantToSearch = false; //views
else if (tableName == "ts_c_attachment") tableWeWantToSearch = false; //text search indices
else if (tableName == "ts_chain") tableWeWantToSearch = false; //..
else if (tableName == "ts_document") tableWeWantToSearch = false; //..
else if (tableName == "ts_phrase") tableWeWantToSearch = false; //..
else if (tableName == "ts_word") tableWeWantToSearch = false; //..
else if (tableName == "ts_word_roots") tableWeWantToSearch = false; //..
else if (tableLabel.indexOf("text index ") == 0) tableWeWantToSearch = false; //..
else if (tableLabel.indexOf("ts index stats") == 0) tableWeWantToSearch = false; //..
else if (tableLabel.indexOf("recorded incremental change") == 0) tableWeWantToSearch = false;
else if (tableName.indexOf("sh$") == 0) tableWeWantToSearch = false;
else if (tableLabel.indexOf("rollback sequence") == 0) tableWeWantToSearch = false;
else if (tableLabel.indexOf("score level") == 0) tableWeWantToSearch = false;
else if (tableLabel.indexOf("pa favorites") == 0) tableWeWantToSearch = false;
else if (tableName.indexOf("syslog") == 0) tableWeWantToSearch = false;
else if (tableName.indexOf("sys_cache_flush") == 0) tableWeWantToSearch = false;
else if (tableName.indexOf("sys_db_cache") == 0) tableWeWantToSearch = false;
if (tableWeWantToSearch){
var searchTable = new GlideRecord(table.getValue("name"));
//make sure it is a valid table first
if (searchTable.isValid()){
//searchTable.setWorkflow(false);
searchTable.addQuery("sys_id", searchId);
searchTable.query();
while(searchTable.next()){
foundRecord = true;
_showFoundRecord();
}
} else {
message = "***** Trying to search an invalid table name called '" + table.getValue("name") + "' - the sys_id of that sys_db_object record is '" + table.getValue("sys_id") + "'";
gs.addInfoMessage(message);
}
}
}
if (foundRecord == false){
gs.addInfoMessage("The record was not found");
}
} catch(err) {
gs.log("ERROR: " + err);
}
function _showFoundRecord(){
var details = searchTable.getDisplayValue();
if (addLink == true) {
details = "<a href='" + gs.getProperty('glide.servlet.uri') + "nav_to.do?uri=" + searchTable.getLink() +"' target='_blank'>" + searchTable.getDisplayValue() + "</a>";
}
message = "Found a record of type '" + searchTable.getClassDisplayValue() + "' (" + searchTable.getRecordClassName() + ") called '" + details + "'";
gs.addInfoMessage(message);
}
})();
and that is where you can write this code:
Mark Correct or Helpful if it helps.
Thanks,
Yousaf
***Mark Correct or Helpful if it helps.***
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 05:47 AM
Hi yousuf
We dont know the table name, Currently I have this requirement.