Share:
Developers » Exception Handling Settings » Exception Handling Scripts

PREVIOUS  |  NEXT

Exception Handling Scripts


Exception Handling scripts are used to catch exceptions from other scripts. They execute as asynchronous tasks, which means they execute simultaneously with the original script, allowing the original script to complete its execution. You can view, create, and modify existing exception handling scripts in the Script Editor workspace. To access the workspace, go to Setup > Development > Scripts


These scripts provide examples for how to work with exception handling: 

  • Exception Handling - 1 - Prepare Entities
  • Exception Handling - 2 - Process Entities
  • Exception Handling - 3 - Handle Exception


These scripts are part of the Exception Handler workflow. You do not need to modify these scripts unless you have a custom need:

  • Exception Handling - Continue - Skip
  • Exception Handling - Process Failed
  • Exception Handling - Retry


These implemented scripts are appended with Impl and we expect you to customize the code according to your needs:

  • Exception Handling - Continue - Skip - Impl
  • Exception Handling - Process Failed - Impl
  • Exception Handling - Retry - Impl


To see which implemented script is used in a specific exception handling case:

  1. Open the Exception Handler case.
  2. In the Exception Details section, click on the Scripts link.
  3. We display the following details that include the implemented scripts used in the exception handling case:
    • Retry script: eh_retry_script_impl 
    • Skip script: eh_skip_script_impl
    • Process fail script: eh_process_failed_script_impl 

You can change the default script that will execute by either changing the default settings in the Exception Handling Settings table, or by adding the appropriate parameter in the specific script code.

Example:

To change the default settings for the Exception Handling - Continue - Skip - Impl script, enter the system ID of your script in the corresponding System ID field in the table of Exception Handling Settings

To only change a particular script, you need to add the desired parameters in the script that will process the exception. See the following code lines in Step 2 of the example in the next section. 

  • To use a different workflow to handle exceptions, you can add the following code, as you can see in code line 51:
    params.put("exceptionHandling.caseType.systemId", "customCaseTypeForHandleExceptions"); 

  • To change the retry implemented script that will be called, add the following code, as you can see in code line 52:
    params.put("exceptionHandling.cf.script.retry.value", "myCustomRetryScriptImpl");


When you add the code to your scripts using the second method above, the default settings are not changed for other processes that may call the script.