logo

NJP

Performing a Code Search on the sys_metadata Table

Import · Feb 04, 2021 · article

In this article, I wanted to share some interesting findings for a ‘code search’ method that I have been using and how it compares to the existing code search in Studio.

This code search method does not require opening of Studio, or any plugins or Share apps to be installed.

For this ‘code search’, I go to the sys_metadata list:

image

And perform a keyword search on the list:

image

The search will look through all tables that extend sys_metadata including ACLs, reports, dictionary entries, etc. As such, one interesting finding was the difference in what I was able to find with this method of code search.

For the search term: ProcessParamParser

Studio returned 1 matching result as follows:

image

Searching the sys_metadata table returned 4 results:

image

Here’s a peek at the NGINX code (that was not found by the code search in Studio):

image

Thanks to my fellow Dev MVP - Eric Riemer - who pointed out to me on slack that the tables and configs for Studio search be found in the sn_codesearch_table so you can add to this if you want to expand what is searchable by Studio. As you can see above, Studio search has the added benefit of highlighting the exact line of code where your search term is found.

image

I am not suggesting that one method is better than the other.

Each method likely has its pros and cons (eg. see Allen A's comment on performance considerations image)

For Studio and similar code search methods, I refer you to these two community articles:

The above is definitely not meant to be a thorough comparison of the code search options, but i thought the differences are interesting and worth sharing. Hopefully this has been helpful to some people/in some situations.

image

View original source

https://www.servicenow.com/community/developer-articles/performing-a-code-search-on-the-sys-metadata-table/ta-p/2311266