Finding Record by Sys ID as an Administrator

brianmurray
ServiceNow Employee
ServiceNow Employee

Hi All,

I have a script with a hard code Sys ID which displays a particular record from the ServiceNow data.   I am not sure if this record (object) is a page, iframe or what.   I am looking for a way to query the ServiceNow database as a System Administrator to find this object.

How can I use the out of the box tools/applications within the ServiceNow to find this object/record to trace it's whereabouts in the database?

Thanks a bunch.

Brian

1 ACCEPTED SOLUTION

Your script should give you an idea which table to query.


View solution in original post

8 REPLIES 8

Ahmed Hmeid1
Kilo Guru

Hi, I've added a script to my blog which you might find useful to find the table



https://servicenowgems.com/2016/08/15/finding-a-sys_id-across-the-system/


HI Ahmed,



I have a sysid, i don't know the table how can I find the corresponding record?


Hi,

Put this in script include:

function findAnywhere(sysid, html) {

            if (html !== true && html.toString().toLowerCase() !== 'true') {

                        html = false;

            }

            var check;

            var tableName;

            var url = gs.getProperty('glide.servlet.uri');

            var table = new GlideRecord('sys_db_object');

            //Make sure we're not looking at a ts (text search) table.

         table.addEncodedQuery('sys_update_nameISNOTEMPTY^nameISNOTEMPTY^nameNOT LIKEts_^nameNOT LIKEsysx_');

            table.query();

            while (table.next()) {

                        try {

                                    tableName = table.getValue('name');

                                    check = new GlideRecord(tableName);

                                    if (check.get(sysid)) {

                                                url += tableName + '.do?sys_id=' + sysid;

                                                if (html) {

                                                            return '<a href="' + url + '">' + url + '</a>';

                                                }

                                                else {

                                                            return url;

                                                }

                                    }

                        } catch(ex) {

                                    //gs.log(ex.message);

                        }

            }

}

 

 

 

 

and in back ground script :

 gs.print(findAnywhere('9ac3fd684fe1020066168ab18110c793'));

 * @param sysid {String} The sys_id of the record you're looking for.

 

You will get a URL With Table name.

Vithusan Jegan1
Kilo Contributor

Click left coiner filter button then set condition like "sys_ID is [your sys id]" then run your filter.

find_real_file.png