Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Fetch context ids of subflows programmatically outside the flow designer

BhagyashriS8790
Tera Contributor

How can I retrieve the context IDs of all subflows that are currently running for a specific RITM using server-side script (outside Flow Designer)? Is there a relationship between the main flow’s context ID and its child subflow context IDs? If I already know the main flow’s context ID, how can I programmatically find all subflow context IDs that belong to it?

1 REPLY 1

Kieran Anson
Kilo Patron

You can query the sys_flow_context table.

  1. Query filtering on source_record and source_table, specifying the ritm sys_id and table name
  2. For each returned result, re-query sys_flow_context, specifying the source_table as sys_flow_context, and the sys_id being the sys_id of the flow returned from query 1
  3. Recursively do this, to get all nested flow calls