Workflow and ServiceDesk Community

 View Only

Learning Workflow -- Exceptions 

Feb 07, 2018 12:30 PM

This tutorial is intended to help you understand how exception triggers work, and the difference between the triggers.  Every Workflow project starts with a "Critical Errors" model, which will catch any unhandled exception, but we want to better-handle our exceptions within each model, so we use one of the Exception Triggers to do so.

The triggers covered here are:

  • Exception Trigger
  • Exception Trigger by Component
  • Exception Trigger by Components
  • Exception Trigger by Exception Type

If a single component in your workflow throws an exception, all 4 exception trigger components exist, and all 4 have conditions which are met by this exception, the priority of the triggers are as follows:

  1. Exception Trigger by Component
  2. Exception Trigger by Components
  3. Exception Trigger by Exception Type
  4. Exception Trigger

An exception trigger outputs the details of the error, as well as the component by which the error was triggered.  Exception Trigger component outputs:

  • ExceptionComponentClassName
    • This is the actual class name of the component which triggered the exception.
    • e.g. LogicBase.Components.Default.Process.SimpleCollectionSort
  • ExceptionComponentName
    • This is the name of the component that triggered the exception, as it appears on the Workflow canvas.
    • e.g. "Simple Collection Sort" or "Sort This Array" or whatever you may have renamed the component.
  • ExceptionTriggerComponentID
    • This is the unique component GUID for the component.  This ID is specific to the component on the canvas and will not change as long as that component exists.
    • e.g. 0cdf7ee7-0c14-11e8-96d6-000c29aca9b1
  • ExceptionTriggerExceptionClassName
    • This refers to the class name of the exception type that was triggered.
    • e.g. System.ArgumentNullException
  • ExceptionTriggerMessage
    • This is the message that is returned from the process as the helpful exception message.
    • e.g. Value cannot be null. Parameter name: array
  • ExceptionTriggerStackTrace
    • This is the detailed exception message.

Attached is a demonstration of how the exceptions are triggered and handled.

To illustrate:

A bit about each notable component on the page:

  • The Initialize Data component is being used to declare (and give initial value to (if desired) declared) variables.  In this case, only the FormCSS variable is being declared.  
    • It's of note that the reason the exceptions in this demo are occurring is because the excepting array was not declared here.
  • The "Form CSS" component is a Merge Text component, and is being used to compile the style sheet for the forms, as well as import the Google fonts used here.
  • The Multi Path Demo component is simply a dummy component used to split the path of the process flow.  In this case, it is being used to initialize the array we're using to trigger exceptions.  This component is statically set to output via the "Straight" path.
  • The "Initialize Array" component is another Initialize Data component, renamed for clarity.  This component is providing the array which will trigger most exceptions in this project, as well as a date variable that will provide the exception for the "Type" path.  The exceptions occur because this component, while upstream, is never encountered because the previous component (Diverge) is set to always output via the "Straight" path.  This means that the target variable in many downstream components does not exist at runtime.
  • The "Exceptions!" form is simply the interface for navigating the exception trigger types.  This is a Form Builder component, renamed for purpose.
  • The "Sort Array" component along the "General" path is a Simple Collection Sort component.  This is being used to attempt to sort the target array, but the exception is triggered because the array variable does not exist at runtime.
  • The "Unique Component Name" component along the "Specific" path is another Simple Collection Sort component.  This was renamed to a unique name to show how the Exception Trigger By Component component works with a component's specific name.  The exception itself is the same as the "Sort Array" component.
  • The "Random" component is the Random Rule component, shortened for space consideration.  This is being used to show that multiple components can be used to trigger the Exception Trigger by Components component.  There's a 50% chance that the True or False path will result, but the exception is caught by the same component, as configured.
  • The "Sort Component 1" and "Sort Component 2" components are Simple Collection Sort components, being used to demonstrate that the Exception Trigger by Components can be configured to target multiple components by name.
  • The "Restart" component is simply a Go To Component By Name component, and is used to keep the canvas clean of lines.  This component can be configured to target another component, and the flow will be diverted to whatever target is specified when this component is reached.
  • The Add Days component has not been renamed, and is used to demonstrate an exception whose type can be targeted and caught by the Exception Trigger by Exception Type component.  If the target date was properly initialized/declared, this component would work as expected.  For our purposes, this triggers an exception to illustrate this point.
  • The Exception triggers are explained above.
  • The "Vars" components are Variables Exist components, and are all used to pick up variables that do not exist along stream lines.  When a trigger occurs, most stream variables are not available.  This component fetches the targeted variables and makes them available downstream of the trigger component.  In this case, we are fetching the FormCSS variable to use on the result and description forms following each exception trigger.  This configuration is not necessary when using the Exception Trigger By Component (singular) component; the variables are carried through with this one, but only this one.
  • The "General", "Specific", "Specifics", and "Type" forms are renamed Form Builder components used to display not only the simple results of the exceptions, but also a detailed description of each type of exception trigger component.

This seems adequate preamble to the demo project itself, which should help further illustrate how each component functions.  Hopefully this project also helps illustrate how each is applicable in a Workflow process.

As always, post questions or comments below and I'll clarify anything that needs it.

Happy exceptions!

Statistics
0 Favorited
0 Views
1 Files
0 Shares
0 Downloads
Attachment(s)
package file
Exceptions Demo.package   1.15 MB   1 version
Uploaded - Mar 11, 2020

Tags and Keywords

Related Entries and Links

No Related Resource entered.