Searching the script field(s) of workflow activities

Michael Domke
Tera Guru

Is there a way to search the various script fields in workflow activities? I need to verify the use of certain table/field uses in workflow activity scripts.

For example, search all workflow activity scripts to see which ones contain "u_software" somewhere in the script. To do this manually will be very time consuming as well as the potential for blurry eyed oversight mistakes.

Thanks,
Michael

1 ACCEPTED SOLUTION

Michael Domke
Tera Guru

To benefit others:

Yes, you can do this search.
1) In the Navigator filter box, type sys_variable_value.list <-- This takes you to the table to search
2) Click on the Filter wizard icon to create a custom filter
--- Table (document) is wf_activity AND
--- Variable.Column Name contains script' OR
------ Variable.Type.Name contains 'script' AND
--- Value contains [whatever you are searching for]

Although, I could not find Variable.Type.Name in the filter wizard. Variable.Type didn't show to have any related fields.


View solution in original post

23 REPLIES 23

seanphelan
Tera Expert

This was a great solution.  Just wanted I needed.  But I did make some enhancements so I thought I would share

  1. renamed ScriptUtils to WorkflowSearcherScriptUtils to me a more unique name 
  2. Added logic to the rendered results to include
  3. Added the ability to search a specific workflow or search all published workflows
    • direct link to the workflow editor for this result
    • added a note if the workflow is currently checked out by someone else
    • is this workflow in an open update set for someone else
    • the table name the workflow is running on
    • What catalog forms will be affected so you can retest (and if its not active its red)
    • A code preview showing the line above and below the matched result

find_real_file.png

Great tool.  I had to modify the query in the WorkflowSearcherScriptUtils at line 30 to get it to work.

 

Not working:  

cExist.addEncodedQuery('document=wf_activity^document=wf_activity^variable.elementLIKEcondition^ORvariable.internal_type.nameLIKEcondition^ORvariable.elementLIKEscript^ORvariable.internal_type.nameLIKEscript^valueLIKE' + searchText + '^document_key=' + wfActivities.getValue('sys_id'));

 

Working:

cExist.addEncodedQuery('document=wf_activity^valueLIKE' + searchText + '^document_key=' + wfActivities.getValue('sys_id'));

Below Script search all the workflows to find a keyword

 

//Use this Fix script to search workflows for a keyowrd

var keyword = 'PROVIDE_YOUR_KEYWORD';
var query = 'valueLIKE'+keyword;
var arr = [];
var tbl = new GlideRecord('sys_variable_value');
tbl.addEncodedQuery(query);
tbl.query();
while(tbl.next()){
var wftbl = new GlideRecord('wf_activity');
wftbl.addQuery('sys_id', tbl.document_key);
wftbl.query();
if(wftbl.next()){
arr.push(wftbl.workflow_version.name);
}
}
for(i=0; i< arr.length; i++){
gs.print(arr[i]);
}

Nagarjun
Giga Contributor

Below Script search all the workflows to find a keyword

 

//Use this Fix script to search workflows for a keyowrd

var keyword = 'PROVIDE_YOUR_KEYWORD';
var query = 'valueLIKE'+keyword;
var arr = [];
var tbl = new GlideRecord('sys_variable_value');
tbl.addEncodedQuery(query);
tbl.query();
while(tbl.next()){
var wftbl = new GlideRecord('wf_activity');
wftbl.addQuery('sys_id', tbl.document_key);
wftbl.query();
if(wftbl.next()){
arr.push(wftbl.workflow_version.name);
}
}
for(i=0; i< arr.length; i++){
gs.print(arr[i]);
}

This is exactly what I need it. Thanks a lot!