Localized Messages for JavaScript Business Rules

When adding an Evaluate JavaScript business condition or an Execute JavaScript business action, messages and translations can be specified. The JavaScript 'Return' or 'Throw' statements are used to display a business rule message.

Return Statement

The return statement is for conditions used to indicate whether the condition is true or false. When Boolean true is returned, the condition evaluates to true. Any other return value will make the condition evaluate to false.

To have a message displayed to the user when a condition evaluates to false, two options are available. The first and most simple is to return a String, as shown in the following example:

return "Object is not ready";

The other option is to return a translatable error message object, making it possible to have the message displayed in a language matching the UI locale. For more information on adding messages, refer to Adding a Localized Business Rule Message in the Business Rules documentation here.

The Return statement is not available in a business action.

Throw Statement

It is possible to deliberately throw exceptions from both actions and conditions if error states are encountered. The exception message can be a translatable message object. For more information on adding messages, refer to Adding a Localized Business Rule Message in the Business Rules documentation here.