where are workflow activity values stored?

randrews
Tera Guru

Like the title says.. where are workflow activity variables stored??

i know that for the catalog the actual values for all variables are on the Variable Ownership table.. and you can put in an item number and find them all...

i know in a background script given the right info you can reference the workflow activity variables via workflow.vars.table_varName

but what table for workflow activities are the variables actually stored on??

to be clear when i talk about workflow activity variables i am NOT talking about the item variables.. but the ones for the workflow itself...

in my specific case i want to find every approval activity in a published workflow that is a user approval where the users variable contains request.requested_for.manager

1 ACCEPTED SOLUTION

ccajohnson
Kilo Sage

You should be able to query the Values [sys_variable_value] table. I used an advanced query to find anything with requested_for in the value field:


var varObj = new GlideRecord('sys_variable_value');


var qString = 'valueLIKErequested_for';


varObj.addEncodedQuery(qString);


varObj.query();


while (varObj.next()) {


  //DO STUFF


}



Had to modify because of copy paste malformed my code.


View solution in original post

6 REPLIES 6

thank you sir... THAT was the table i was looking for!


Just in case anyone else needs to do something similiar, this can be run in a background script and will spit out the names of all workflows where the query string is in there... just a change to the encoded query and you can find what you need!




var tablename = 'sys_variable_value';


var wf_tablename = 'wf_activity';


var wf_q_string = 'sys_id=';


var q_string = 'valueLIKErequest.requested_for.manager';


var v_rec = new GlideRecord(tablename);


v_rec.addEncodedQuery(q_string);


v_rec.query();


while(v_rec.next()){


//gs.print('v_rec key is ' + v_rec.document_key);


        if(v_rec.document_key != ''){


                  var wf_rec = new GlideRecord(wf_tablename);


                  wf_rec.addEncodedQuery(wf_q_string + v_rec.document_key);


                  wf_rec.query();


                  if(wf_rec.next()){


                            gs.print(wf_rec.workflow_version.getDisplayValue());


                  }


        }



}



____________edit one last tweak to only show published workflows---------------------------------




var tablename = 'sys_variable_value';


var wf_tablename = 'wf_activity';


var wf_q_string = 'sys_id=';


var q_string = 'valueLIKErequest.requested_for.manager';


var v_rec = new GlideRecord(tablename);


v_rec.addEncodedQuery(q_string);


v_rec.query();


while(v_rec.next()){


//gs.print('v_rec key is ' + v_rec.document_key);


        if(v_rec.document_key != ''){


                  var wf_rec = new GlideRecord(wf_tablename);


                  wf_rec.addEncodedQuery(wf_q_string + v_rec.document_key);


                  wf_rec.query();


                  if(wf_rec.next()){


if(wf_rec.workflow_version.published){


gs.print(wf_rec.workflow_version.getDisplayValue() + ' published value is ' + wf_rec.workflow_version.published);


                              }                                                  


                  }


        }


}