ServiceNow is promoting the LowCode / No-Code approach very strongly with their flow engine. Flow is the new way of creating a workflow fast and without any huge programming. I’m not very familiar with the ways how it worked in past releases as I started out with the Paris release and with that, I already entered the world of the flow engine. But it doesn’t matter how easy it is to create a flow, the most important part is that the flows run without errors. And here is some kind of a lack when it comes to flows. They get tracked of course if they are running into an error but there is no kind of information or something
As a system administrator or even a workflow responsible administrator, I would like to know when a flow throws an error so I can investigate why it happened and prevent it in the future. And we all know that issues will come up nobody thought of during development and testing.
How to keep track of errored ServiceNow flows
There is actually a table that tracks all flows with all their status: sys_flow_context
Here you can filter for errored flows and check each one individual what was the root cause of the issue. This is one way you can actually check from time to time how your flow engine performs, how many flows are open, and what errors came up.
But… often you need to get informed immediately if a flow runs into an error. You have to act on this, prevent it in the future, etc. So why not leverage the flow engine to check for flows with an error state?
Create an incident when a flow is in error state
If you are using the IT Service Management module (probably most ServiceNow customers) you can actually create a flow that checks the “sys_flow_context” table and create an incident as soon as a flow gets into the state “Error”.
Step | Description |
Trigger | Start if a flow is created/updated and has the state “Error” |
Action 1 | Create an Incident Record |
Action 2 | Update the Incident Record with whatever fields you need. My updates: – Short Description: Flow Error: <Trigger->Flow engine context Record->Name – Work Notes: Dynamic Link to the actual flow with the error |
For the Work Notes link you can use the following script which will dynamically create the link to your respective flow with the error:
var flowSysId = fd_data.trigger.current.sys_id; var url = '/$flow-designer.do#/operations/context/' + flowSysId; return '[code]<a href="'+url+'" target="_blank">Go to Flow</a>[/code]'
If you know get a new or updated flow you can directly act on the incident that gets created.
Have fun with that and improve your flows!