toggle scripting in flow designer Error Handler

BoHyun Jung
Mega Sage

Can't I use toggle scripting on Error handler? If possible, please let me know how to do it

 

[not Error Handler]

BoHyunJung_0-1719559360195.png

[Error Handler]

BoHyunJung_1-1719559396731.png

 

5 REPLIES 5

Yashsvi
Kilo Sage

Hi @BoHyun Jung,

Yes, you can use toggle scripting on an Error Handler in ServiceNow. The toggle scripting feature allows you to enable or disable scripting for specific activities, including Error Handlers. Here’s how you can do it:

  1. Navigate to the Flow Designer:

    • Go to Flow Designer by typing Flow Designer in the application navigator and selecting it from the list.
  2. Open Your Flow:

    • Find and open the flow you want to add an Error Handler to.
  3. Add an Error Handler:

    • Click on the action or flow logic where you want to add the Error Handler.
    • Click on the More options (three dots) and select Add Error Handler.
  4. Toggle Scripting:

    • In the Error Handler configuration, you will see an option to toggle scripting.
    • Click on the Toggle Scripting button. This will switch the view from the standard interface to a script editor.
  5. Script:

 

(function execute(inputs, outputs) {
    // Custom error handling logic
    var errorMessage = 'An error occurred in the flow: ' + inputs.error.message;
    gs.error(errorMessage);
    
    // Optional: create a task or notify users
    var gr = new GlideRecord('incident');
    gr.initialize();
    gr.short_description = 'Flow Error';
    gr.description = errorMessage;
    gr.insert();
})(inputs, outputs);

 

Save your changes and make sure the flow is activated for the changes to take effect.

Thank you, please make helpful if you accept the solution. 

Hi @Yashsvi 

 

Can you capture the screen for me to understand?

I don't understand what you mean by just looking at the writing.

Hi @Yashsvi 

 

What should I do here? It's hard to proceed as you explained.

BoHyunJung_0-1719794293753.png

 

Mahesh Tiwari
ServiceNow Employee
ServiceNow Employee

Hi Bo, 
Please see attached gif file you should be able to see the toggle script option under error handler for some of the actions and flow logic like this
Feel free to mark this answer helpful if this answers your query 

 

Toggle_script_error_handler.gif