Searching Script Fields in ServiceNow Workflow Activities
- nathanlee142
- May 13
- 3 min read

For ServiceNow developers and administrators, workflows are the backbone of many automated processes. These workflows often contain intricate scripts within their activities to perform specific actions. As the complexity and number of workflows grow, the need to quickly locate specific code snippets or references within these scripts becomes crucial. Manually sifting through each workflow activity to find a particular string or keyword can be incredibly time-consuming and prone to human error. This article provides a practical and efficient method to search across the script fields of your ServiceNow Workflow Activities, saving you valuable time and ensuring accuracy when auditing or updating your automated processes.
Imagine you need to identify all Workflow Activities that reference a specific custom table or field, perhaps named "u_software." Manually opening and inspecting the script of each activity across all your workflows would be a daunting task. Fortunately, ServiceNow provides a way to query the underlying data that stores this information, allowing for a much faster and more reliable search.
The Solution: Leveraging the sys_variable_value Table
The key to efficiently searching Workflow Activity scripts lies in understanding how ServiceNow stores the data associated with workflow activities. The script fields you see in the workflow editor are actually stored as records in the sys_variable_value table. This table holds the values of variables used in various ServiceNow components, including Workflow Activities.
Here's a step-by-step guide on how to use this table to search for specific text within Workflow Activity scripts:
Navigate to the Table: In the ServiceNow navigation filter, type sys_variable_value.list and press Enter. This will open a list view of all records in the sys_variable_value table.
Open the Filter Builder: Click on the filter icon (usually represented by three horizontal lines) to open the filter conditions builder.
Set the First Condition: You need to narrow down the search to only those variable values associated with Workflow Activities. To do this, add the following condition:
Field: Table (or Document)
Operator: is
Value: wf_activity
This condition ensures that you are only looking at records related to Workflow Activities.
Set the Second Condition to Target Script Fields: Now, you need to specify that you are interested in the content of script fields. Add the following condition:
Field: Variable.Column Name
Operator: contains
Value: script
This condition targets variable values where the associated column name in the wf_activity table contains the word "script," which is common for script fields within Workflow Activities.
Set the Third Condition for Your Search Term: Finally, add the condition to search for your specific text. For example, to find all scripts containing "u_software," add:
Field: Value
Operator: contains
Value: your_search_term (e.g., u_software)
Run the Filter: Click the "Run" button to apply the filter.
The resulting list will display all records in the sys_variable_value table that meet your criteria. Each record will represent a script field within a Workflow Activity that contains your specified search term. You can then open these records to identify the specific workflow and activity where the term is used. The "Document key" field in the search results will provide the sys_id of the wf_activity record, which you can use to directly navigate to the activity in the Workflow Editor.
Practical Example:
Let's say you want to find all Workflow Activities using a specific integration variable named "integration_endpoint." You would follow the steps above, replacing "your_search_term" in step 5 with "integration_endpoint." The search results will then show you every script field across all your workflows where this variable is mentioned.
Alternative Solution: Using a Fix Script
For a more programmatic approach, you can also use a Fix Script to search across all workflow activity scripts. Here's an example script that prints the names of workflows containing a specific keyword:
JavaScript
var keyword = 'your_search_term'; // Replace with your desired keyword
var query = 'valueLIKE' + keyword;
var workflowNames =;
var varValue = new GlideRecord('sys_variable_value');
varValue.addEncodedQuery(query);
varValue.query();
while (varValue.next()) {
var workflowActivity = new GlideRecord('wf_activity');
workflowActivity.addQuery('sys_id', varValue.document_key);
workflowActivity.query();
if (workflowActivity.next()) {
workflowNames.push(workflowActivity.workflow_version.name);
}
}
workflowNames.sort();
for (var i = 0; i < workflowNames.length; i++) {
gs.print('Workflow Name: ' + workflowNames[i]);
}
Remember to replace 'your_search_term' with the actual text you are looking for. This script iterates through the sys_variable_value table, finds records where the "value" field contains the keyword, and then retrieves the name of the associated workflow.
Conclusion
Efficiently searching script fields within ServiceNow Workflow Activities is crucial for maintaining, auditing, and updating your automated processes. By leveraging the sys_variable_value table and applying the appropriate filters, you can quickly and accurately locate specific text within these scripts. The alternative Fix Script method offers a programmatic way to achieve the same result. The next step is to apply these techniques to your ServiceNow instance whenever you need to find specific code or references within your workflows, saving you significant time and effort.