Subflow triggered via script with inputs but unable to find flow execution easily to cancel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
In general, we ran a script to trigger a subflow for users who hadn't met a specific requirement and it sends them reminder emails every 2 weeks until they meet the requirement. We have now identified a subset of the population who should be exempted and I need to cancel their flow execution so they no longer receive the reminder emails. However, since it was triggered from a scheduled script, the Source Record, which we typically use to search for flows, is blank. My thought is to create a group for "Exempted Users for this requirement", then have a business rule that runs after a user is added to that group that would search for this subflow execution for this particular user (user recorded provided as one of the inputs) and cancel it. Is there a way to search flow executions based on an input provided to start the flow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday - last edited yesterday
This information may not be accurate depending on your version of ServiceNow but the approach should be consistent.
There should be a calling_source field that will let you query the sys_flow_context table to find the executions related to the original script. You would then need to iterate through these to check the associated user. To check the user, use the sys_id of the sys_flow_context reference to lookup the value of the variable that contains the user information. In Zurich it is the sys_flow_context_inputs_chunk table that contains the execution values for inputs.
So you may need to do it in script because of security around the sys tables but it would look something like this:
- query records on sys_flow_context where calling_source equals original script
- for each record
- query sys_flow_context_inputs_chunk where
- document_id is sys_id of sys_flow_context record
- field is user field
- data contains user data
- if record count is greater than zero
- update sys_flow_context
- query sys_flow_context_inputs_chunk where
Keep in mind the tables used may vary from version to version and this is based on my knowledge of the Zurich version. You should be able to determine the correct tables and variables by digging through the sys_flow tables in your instance or by generating the associated records in a dev/test instance to identify values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Thanks for the table information @John Gilmore. I'll take a look at this and see if I can get it to work!