Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Flow Designer - How to find FLOWs based on the triggering table AND conditions

GavinNZ
Tera Contributor

I often need to analyse what triggers are configured and cannot find where to do this with FLOWs. For example, if I want to find all FLOWS are triggered by change_request.state I cannot see a way to do this. This is a backwards step for us that often are asked to decipher the novel, poor, and erroneous configuration on a platform. Now it seems we must manually look through hundreds of FLOWS to find the needle, instead of the simple search I run on Business Rules.

 

  1. I have found the table sys_hub_trigger_instance_v2 which has the trigger inputs that are encoded. It is not Base64 encoded, tried to decode it.
  2. I found the function in the Configuration Menu for a table that adds a column to a List Query javascript:sn_flow.AssociatedFlows.getFlows("change_request")
  3. There are some APIs available but the method sn_flow.AssociatedFlows.getFlowsWithTriggerDetails(tableName) just returns the FLOW, and thir tigger type and they do not seem to be accessible or documented
  4. There are other posts asking the same thing but none get to the detail of searching by the TABLE, Trigger, and the CONDITION. 
    1. Identify active flows running on particular table - ServiceNow Community
    2. Solved: How to find out the flow designers created or defi... - ServiceNow Community
    3. Find flows that trigger actions on a table - ServiceNow Community
 
var tableName = 'change_request';
var rawJson = sn_flow.AssociatedFlows.getFlowsWithTriggerDetails(tableName);

// Print the raw JSON string
gs.info('Raw JSON for table: ' + tableName);
gs.info(rawJson);

 

Business Rules

In Business Rules I can use the LIST and Filter by table, FilterConditions, or Condition, and you have your list. I do this regularly when I start diagnosing an issue or start on a new customer instance. https://[instance_name]].service-now.com/now/nav/ui/classic/params/target/sys_script_list.do%3Fsysparm_query%3DcollectionSTARTSWITHincident%255Efilter_conditionLIKEstate%26sysparm_first_row%3D1%26sysparm_view%3D

GavinNZ_0-1765138212572.png

 

 

 

 

1 REPLY 1

Jordan Blake
Kilo Sage

So, I had this same requirement because we needed to identify hard-coded filter conditions on Flow triggers we knew were going to change.

 

First, you can't decode the "sys_hub_trigger_instance_v2" record without unzipping if after, and there is not a native ServiceNow "unzip" method available to us. (even though it seems to exist in GlideStringUtil, but inaccessible from our scopes). You can export and run all that in Python if needed, but thankfully, I found an SN solution.

 

To filter on Flows and their Trigger Table/Conditions:

  1. Create a DB View joining sys_hub_flow and sys_flow_record_trigger on the remote_trigger_id field
  2. Leave Left join false if you only want Flows which use record triggers, else you can Left join to see all Flows even if they do not have a record trigger

This is the best I got right now. I'm still looking into how I may be able to join filter conditions for Actions as well (Record query, etc).