Business Process Automation

Error Handling

This page is accessed via Business Process Automation > Agents and Milestones > Automation Agent. It is on the Error Handler tab.

You can use the Error Handler to configure how the system reacts to an error condition during the execution of an agent. By default, the agent error handler is empty which means the system does nothing if an error occurs (aside from logging the error).

An error handler definition is a collection of actions. If an error occurs during the execution of the agent body, the actions listed in the error handler are run sequentially. However, if an error handler action generates an error, the error is logged and the agent stops.

When an agent error handler is invoked, it does not pass any context from the agent body. In other words, the error handler knows nothing about the context in which it was invoked, other than the business object type and ID associated with the agent.

Error Variables

When an agent generates an error, error variables are available. These variables can be used on the Error Handler portion of your agent in a number of different ways, but can require different syntax depending on how they are being used.

Use case

I have integration coming in that is doing something to a business object, in this case an item in OTM. If that agent fails, I want to take some action, such as notify a user or create a Refnum on the business object with information about the error.

The variables can be used to generate a user-defined subject line that can be sent to a contact in the event the agent fails.

$error.message - was generated at line $error.action.sequence

When the notification is sent to the user, the subject line will show, by default, the object the agent was working on, the $error.message variable and the $error.action.sequence, which is the line number within the agent where the error was generated.

Below is an example of the subject line received when the agent generated the error:

Item COSY - ERROR RAISED IN THE AGENT USING AGENT ACTION - was generated at line 2

The same variables can be used as part of a direct SQL Update to create a new Refnum with the error message for the Refnum value.

The following is a sample of a direct SQL update statement that could be used:

insert into ITEM_REFNUM (ITEM_GID, ITEM_REFNUM_QUAL_GID ,ITEM_REFNUM_VALUE,DOMAIN_NAME)
values ($GID, 'KAW.AGENT_ERROR',${error.message},'KAW')

Note: Unlike the subject line example above, in order to use these variables as part of a direct SQL statement, the variable would need to be surrounded by {}'s for them to be understood when run.

Related Topics