Using error codes in business rules
Error codes are used within a business rule so that the output can be translated. An error message is only populated when the business rule is called from the parent map.
If business rule output is not set to a specific error code or set to an invalid error code, a message appears stating "error not found".
After completing the business rule evaluation, a localized error code message (if configured) appears automatically based on the locale. For a form, the message appears based on the locale of the browser; for a process, it appears based on the locale of the Core Worker.
To use an error code in a business rule, use the following procedure:
-
Make sure that the required error codes are available.
Create String variable
If the output variable is set to String, you can set an error code or error code message.
-
Click
for
New variable.
The New variable dialog box is displayed.
-
Enter a unique
Name for the variable.
By default, the name of the variable becomes the ID of the variable; however, you can change the ID if needed.
- On the Type list, select String. (Default: String)
- To set the variable as output, select Output and provide a value.
- Select Error code or Error code message (default: Static) for Value.
- Click Add another to add as many variables as needed without navigating away from the New variable dialog box, or click Add and close to add one variable and close the dialog box.
Add an Expression activity
Configure the Expression activity to define a rule for performing operations on data.
-
Add activity to the map.
By default, the Configuration tab is open in the properties panel of the activity.
- Change the default Name of the activity to something meaningful.
- On the Type list, select .
-
Click
for
Configuration.
The Expression dialog box is displayed.
- On the Target variable list, select the variable you created for holding the error code or error code message.
- Optional. Enter a Description for the expression node.
- Right-click on the rule editor and define an Expression using the Error code.
-
To validate the expression, click
Validate.
If the expression rule is invalid, an error message appears stating "error not found".
-
Optional. To ensure the results and format are as expected, click
Test.
The Test expression dialog box displays the variable values.
-
Click
Execute test.
The expression is executed, and the test result shows the error code message. You can change the variable values and retest the expression if needed.
- Click Add.
- Save or release the process map.