How Do I Determine the Flow Action from the Flow Context?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2025 07:52 AM - edited 04-20-2025 08:59 PM
From a Flow Context [sys_flow_context] record, how do I get a script to determine which flow action it is on?
I need to know the flow name (easy), flow action name, and flow action order that a given record is on for a UI element that I am developing. I don't see a reference or indication of the flow action anywhere on the sys_flow_context record, though. However, it must be possible since, if you open such a record in the flow designer, it is able to tell you what flow action the context is waiting on.
Here's the jist of what I'm trying to do, represented via pseudocode:
var current = ... (predefined GlideRecord)
var flowContext = new GlideRecord('sys_flow_context');
flowContext.addQuery('source_record', current.sys_id);
flowContext.addQuery('state', 'WAITING');
flowContext.query();
while (flowContext.next()) {
// Retrieve Flow & Flow Action
var flow = new GlideRecord('sys_hub_flow');
flow.get(flowContext.flow); <=== Easy enough.
var flowAction = [ummm...]; <=== How do I get to this, though?
// Use Flow Name, Action Order, & Action Name
gs.log('flow.name is ' + flow.name);
gs.log('action: #' + flowAction.order + ' ' + flowAction.name); <=== This is the end result needed
}
Please assist, thanks!
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2025 08:03 PM
it's difficult to determine this as there are lot of tables involved when it comes to flow and it's execution
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2025 08:16 PM - edited 04-20-2025 08:32 PM
Don't give up, we can do it! 😉
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 08:13 AM - edited 06-05-2025 08:21 AM
@JosephW1 hi
😁nice one
A little time has passed, but I'm looking for similar things - found my flow action in table "sys_hub_action_type_definition".
Plus think "sys_hub_action_instance" may be a many-to-many across the flow and action tables

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2025 02:05 PM - edited 06-06-2025 02:08 PM
I also came across those tables.
My problem with sys_hub_action_instance is that it's not a complete m2m table, as it only has 5 action instances for a sample flow of mine, yet the sample flow has 12 actions in Workflow Studio. This shows that it's incomplete. (It has 3 update record actions and 2 send notification actions, but lacks 4 if-checks and 3 waits)
sys_hub_action_type_definition seems to just be the master action definitions, not our copies/instances of each master definition, so it does not contain my instances of each definition. It might be useful later, but not at the moment.