How to search code in workflow or other places beyond "code search" scope?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2024 01:04 AM
How to search code in workflow or other places beyond "code search" scope? Code search can only search code script, business rules, but can't search in workflow and some other places, how to search within workflow code? thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2024 02:39 AM
Directly query the Workflow Version table (wf_workflow_version), where the actual workflow scripts and conditions are stored. This can be done via the Background script or by creating a custom application/script to query this table and search for specific strings in the script or condition fields.
var searchText = "your_search_term_here"; // Replace with your search term
var wfVersionGR = new GlideRecord('wf_workflow_version');
wfVersionGR.addQuery('script', 'CONTAINS', searchText); // Searches in script fields
wfVersionGR.addOrCondition('condition', 'CONTAINS', searchText); // Searches in condition fields
wfVersionGR.query();
while (wfVersionGR.next()) {
gs.info("Found in Workflow: " + wfVersionGR.name.toString() + ", Version: " + wfVersionGR.version.toString());
}
Scripts might also be stored in individual workflow activities. You can query the wf_activity table where individual activities are stored and search for your code snippets in the relevant fields (like conditions, scripts, etc.).
var searchText = "your_search_term_here"; // Replace with your search term
var wfActivityGR = new GlideRecord('wf_activity');
wfActivityGR.addQuery('script', 'CONTAINS', searchText); // Searches in script fields
wfActivityGR.query();
while (wfActivityGR.next()) {
gs.info("Found in Workflow Activity: " + wfActivityGR.name.toString());
}
Unfortunately, there is no OOB way to find these otherwise.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2024 05:14 AM
Unfortunately, the scripts in the wf_activity table are not stored in a field called script. They are in a field called variables. With that in mind, you could query the sys_variable_value table with the following:
var searchText = "ALMOST THERE"; // Replace with your search term
var searchTable = "wf_activity"; // Replace with your table name
var wfActivityGR = new GlideRecord('sys_variable_value');
wfActivityGR.addQuery('document', 'CONTAINS', searchTable); // Searches for specific table (or comment out to search all tables)
wfActivityGR.addQuery('value', 'CONTAINS', searchText); // Searches in script fields
wfActivityGR.query();
while (wfActivityGR.next()) {
gs.info("FOUND IN : " + wfActivityGR.document_key.getDisplayValue());
}
- Brian
If my answer helped you in any way, please then mark it as helpful or correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2025 03:27 AM
How can i get the workflow name also?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2025 03:31 AM
you can inspect [wf_activity] and [sys_update_xml]
- for both use the ".filer", it allows you to access the table with no records, first you select your conditions and then you search with applied conditions, it shall avoid the long search in excessive tables
Type "sys_update_xml.filter" and press enter:
Loaded with no records.
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */