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

Erik Gunther2
Kilo Guru

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.

11 REPLIES 11

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.

Very helpful.  Thanks for returning to document this in the ticket.  Why is this stuff so hard to find?  This platform sucks.

LearnerNow
Mega Guru

@Erik Gunther 

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.

 

find_real_file.png

Hi, I am looking out for the same. Any solution to get the context id of the flow triggered by an RITM ?