Created
March 9, 2019 05:03
-
-
Save eetee/a8fbd397040d487e1905af126185063d to your computer and use it in GitHub Desktop.
SN - Searches script fields for term
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( | |
function() { | |
var DEBUG_THIS_SCRIPT = false; | |
var SEARCH_TERM = ''; | |
var searchTableField = function (table, field, searchTerm) { | |
var gr = new GlideRecord(table); | |
gr.addQuery(field, 'CONTAINS', searchTerm); | |
gr.query(); | |
if (DEBUG_THIS_SCRIPT){ | |
gs.info('looking for table:field:searchTerm ' + [table, field, searchTerm].join(':') + 'results: ' + gr.getRowCount()); | |
} | |
var results = []; | |
while(gr.next()){ | |
results.push(gr.sys_id); | |
gs.info('Found in table:field:sys_id ' + [table, field, gr.sys_id].join(':') + ' URL: ' + '/nav_to.do?uri=' + table + '.do?sys_id=' + gr.sys_id); | |
} | |
return results; | |
}; | |
gs.info('Beginning script search for: ' + SEARCH_TERM); | |
var gr = new GlideRecord('sys_dictionary'); | |
gr.addQuery('internal_type.label', 'CONTAINS', 'script'); | |
gr.query(); | |
while (gr.next()){ | |
if (DEBUG_THIS_SCRIPT){ | |
gs.info('querying table: ' + gr.getValue('name') + ' field: ' + gr.getValue('element')); | |
} | |
searchTableField(gr.getValue('name'), | |
gr.getValue('element'), | |
SEARCH_TERM); | |
} | |
gs.info('Script search for: ' + SEARCH_TERM + ' ended.'); | |
} | |
)(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Todo:
Add better logging prefix for search
Searching for fields where "javascrpit: " calls are made