Need one page to search all scripts - IDEAS?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2012 10:30 AM
I can't be alone. You know it is out there. A chunk of script buried somewhere in the system. You've seen it, you may have even modified it. But where, oh where has it gone?
Can someone help me figure this out. I'm not sure how to implement it: complex filter, ui page, etc.
Check this out?
https://demo10.service-now.com/sys_dictionary_list.do?sysparm_query=internal_type%3Dscript%5EORinter...
There are 111 fields that are either type script or script_plain. That's a lot of places to LOOK.
I'd like to have a single page that has a search box that searches all those fields using "CONTAINS", then returns the table, name, script, active, updated columns.
Sure I know we can use the list views for common script locations. I've used it for business rules, client scripts, and ui actions separately.
Here is an example searching for business rules with "getDisplayValue":
https://demo10.service-now.com/sys_script_list.do?sysparm_query=scriptLIKEgetDisplayValue
Would that need to be a ui page with jelly to loop over the table types, then include the list view of each result? Any thoughts?
I'd like to create the module and put it in the system definition application on the left-nav visible to administrators.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2020 01:35 PM
EDIT: Or, check out the second google result which shows the Code Searcher in studio:
https://community.servicenow.com/community?id=community_blog&sys_id=136caea1dbd0dbc01dcaf3231f96198a
I needed to search the scripts, but I don't really need end users to do it, so I took your query and stuffed it into a GlideRecord and created a script. I'm not totally sure if this is exhaustive or not, but it should suffice for most needs.
queryText = 'getDisplayValue';
var dict = new GlideRecord( 'sys_dictionary' );
dict.addQuery( 'internal_type=script^ORinternal_type=script_plain^nameNOT LIKEvar__' );
dict.query();
while( dict.next() ) {
//gs.info( 'table: ' + dict.name + '. element: ' + dict.element );
rec = new GlideRecord( dict.name );
rec.addQuery( dict.element, 'CONTAINS', queryText );
rec.query();
while( rec.next() ) {
gs.info( ' Found: table: ' + dict.name + '(' + rec.getClassDisplayValue() + ', ' + rec.getDisplayValue() + '). sys_id: ' + rec.sys_id + '. element: ' + dict.element );
}
}
If anyone has tweaks post a reply.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2020 05:25 PM
There are 5 projects on Share that do Code Search
https://developer.servicenow.com/connect.do#!/share/contents?page=1&keyword=code%20search
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2020 01:41 PM
In Studio, in the top right, there is a thing called "Code Search". If you type in the phrase you are looking for there, it will search all of your code files, at least if you are in an application. Maybe that could be used somehow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2020 04:08 PM