How To: Use The Error Event And Method
You can use error events and methods on a view or form. This allows you to specify custom rule actions and conditions to be followed, while using error system values such as error message, detail and type. When an error occurs, it attempts to find something to resolve the error, if nothing is found to resolve it with, the default error handling is used. The Stop rule execution and Continue to next execution rule actions can also be used to determine whether execution of the next handler should continue or not. In the Rules Designer, you can also raise your own custom errors via the error method provided. In mappings you can specify the values for the error context that is used.
You can use the Error event and method with the following events and actions:
Type | Description |
---|---|
Event | When the Form raises an event |
Event | When a View raises an event |
Action | Execute a View method |
Action | Execute a Form method |
The error context available consist of the following:
- Error Message
- Error Detail
- Error Type
Potential errors that may occur at runtime and can be handled differently include:
- Cannot execute SmartObject methods
- SmartObject method doesn't exist
- ID does not exist
- ID cannot be loaded
- Can not send a mail
- Can not start a workflow
- Can not access a worklist item
- Use one of the following events in a rule and select in Error.
When the Form raises an event
When a View raises an event - Add conditions and actions to the rule definition as required. One example is to show a message to the user. Configure the message by using the error system values from the Context Browser as shown below or by using your own details.
OR
- Use one of the following actions and select the error method
Actions:
Execute a method on the View
Execute a method on the Form - Configure the error method by providing input mappings
OR
- Use the if an error occurred condition as shown below
- When creating a custom error, it is advised to use conditions to check the validity of the error. Using custom errors can create confusion if the error context is not in sync with the user experience.
- When an error occurs on a view on a form, the error handler will attempt to handle it via the view’s error handling and then revert to the form's error handling if nothing was found. In the case of no error handling being specified at all, default error handling will apply.
- The following order is used when searching for error handlers on error conditions (depending on the origin):
- Search for a valid error handler in the rule
- Then search for a valid error handler in the view
- Then search for a valid error handler in the form
- Then apply the default error handling if nothing was found on the previous levels