Error Handling in Subflow

Henri Muldre
Tera Guru

Hi,

I have created a subflow which I triggers from BR using sn_fd.FlowAPI.getRunner().

This was required as subflows can accept proper inputs and I need to trigger this flow from sc_request level with advanced conditions, which are not available for the main Flow trigger record insert conditions. ServiceNow also support this approach: Types of flows and when to use them (You want to start a flow by calling it from another flow or script).

 

All is working well in the Subflow, except the Error Handler.

 

In the Flow which I had before, if a custom action threw an error (Don't treat as error=FALSE), the Error Handler actions were triggered and it worked fine. I also inspected that the Flow status in Execution details was Completed (error caught):

Henri_0-1699609035377.png

 

which then triggered Error Handler actions:

Henri_1-1699609117813.png

 

In the Subflow however, same exact logic applies, but I no longer get Completed (error caught), but I get Error instead:

Henri_2-1699609441746.png

 

Could it be that the reason why Error Handler does not run is because I triggered this from the TEST button and not the BR script using FlowAPI?

 

Due to this, the Error Handler actions are skipped and look like this in execution history:

Henri_3-1699609625149.png

 

 

This is what it looks like in the subflow for this custom action:

Henri_6-1699610272837.png

 

This is what it looked liked before in the flow (same exact custom action):

Henri_5-1699610079852.png

 

According to documentation:

  • Completed (error caught): Generated when a flow identifies an error and executes the actions, flow logic, or subflows in the Error Handler section successfully.
  • Completed (error skipped): Generated when an action continues running after a step fails.
  • Error: Generated when an error is not identified.
    • An error occurs in a flow while the Error Handler is disabled.
    • An error occurs in the Error Handler section.

The whole point of the Dont't Treat as Error = FALSE was to catch the error and then go to Error Handler. If I keep it as TRUE, then the custom action will have state of Completed (error skipped) and the Subflow will keep running, which is unwanted behavior.

 

Any suggestions how I can trigger the Error Handler inside the Subflow if an error occurs?

1 ACCEPTED SOLUTION

Henri Muldre
Tera Guru

I ended up disabling the Error Handler completely in the Subflow and moving the error handling actions behind an IF condition and modifying the custom action's Dont't Treat as Error to TRUE instead.

Henri_1-1699631868651.png

 

View solution in original post

1 REPLY 1

Henri Muldre
Tera Guru

I ended up disabling the Error Handler completely in the Subflow and moving the error handling actions behind an IF condition and modifying the custom action's Dont't Treat as Error to TRUE instead.

Henri_1-1699631868651.png