Functions.throwError

From AgileApps Support Wiki
Revision as of 23:00, 20 December 2010 by imported>Aeric (Text replace - 'throwError(' to 'Functions.throwError(')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Functions.throwError(key [, String[] args])
Description
Element Display Type Description
key string

A category name, followed by '.' and a message or label identifier (a "token").
Example: #categoryname.tokenname

String [] args string Optional

Declares an array of Strings in Java (or Arguments)

  • If arguments are passed, the call expects a token
  • If no arguments are passed, the message alone is displayed
Syntax
void = Functions.throwError(String key [, String[] args])

If no arguments are needed, use:

Functions.throwError("#custom.label",null)
Return
  • Returns the message configured on the key in the Translation Workbench
  • If no key is configured in the translation workbench, then the passed key is returned


Example
This example checks a parameter passed to it to see if it is equal to "Acme". If it is, the code calls throwError to display an error message saying that the account cannot be "Acme".
if(requestParams.get("name").equals("Acme"))
{
    // message "Account cannot be Acme" will be shown to the user in the UI.
    Functions.throwError("Account cannot be Acme");
}
else
{
    // Normal business logic.
}


To include new lines in the message, specify <br>:

Functions.throwError(“Include <br> for <br> newline”);