How to get the Flow sys_id (sys_flow_context.sys_id) from the trigger record sys_id?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2019 01:37 PM
In a background script editor, I successfully ran the following methods to cancel a Flow Designer workflow:
var gpa = new sn_ph.GlideProcessAutomation('91dd1c84dbc73b849aab755a8c961993');
gpa.cancel('manually cancelled');
My issue is that this method requires the sys_id of the sys_flow_context record. If I'm on the record that triggers the flow, how do I get from the trigger record to the sys_flow_context sys_id?
When I look at how sc_req_item is implemented (trying to ascertain how this was done elsewhere), it has a Flow Context field. Do I need to do the same thing - add this field? If so, then from Flow Designer, how do I retrieve the sys_flow_context sys_id of the executing workflow in order to update the trigger table Flow Context field? Also, the link between sys_flow_context and trigger record must be available somewhere for this to work in the first place so I would think creating the Flow Context field should be unnecessary.
Note: I also did a search for GlideProcessAutomation in docs.servicenow and didn't find anything.
In addition, when I check the sys_flow_context table, there are 2 fields: Source Table and Source Record, which appear to be the right fields, but unfortunately, they are empty for my existing workflows.
- Labels:
-
flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2021 12:48 PM
I couldn't find the trigger record to context record lookup in sys_flow_plan_context_binding but in sys_flow_context there is a Source Record field with the trigger info. I'm on Quebec.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2020 05:01 PM
Very helpful. Thanks for returning to document this in the ticket. Why is this stuff so hard to find? This platform sucks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2020 07:51 AM
I found this thread as I was searching for similar issue. I need to get the context ID of the flow triggered by an RITM.
I am not sure that the Hash Code of the table sys_flow_plan_context_binding contains this information, as it's not a reference field, and it's not clear how to get the id from this field.
Do you have further details about this table, or a link to a documentation of the table.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2020 06:50 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2021 03:28 AM
Hi, I am looking out for the same. Any solution to get the context id of the flow triggered by an RITM ?