Building Constraint Exception Messages
When a SQL constraint exception is thrown from the application database,
the IDO Request layer catches the exception and can build a translatable
message from the SQL constraint name and type, if a message for that constraint
name exists in the ObjectMainMessages table. Different constraints can
use the same basic message, which varies only by the different object
names that are referenced in the message text. For example, many constraint
exceptions could be reported to a user with this basic message:
The &1 entered already exists
where the &1 substitution
expression could refer to any one of hundreds of different objects.
However, the text (or the object name that references the text) to be
substituted cannot be passed when the constraint exception occurs. The
IDO Request layer can only pick up the constraint name and type from the
caught exception. The ObjectBuildMessages table contains child records
that reference either a Message Number defined on the Maintain
Application Messages form or another Object Name defined on the
Maintain Application Message Objects
form for the text to be used for each substitution expression that exists
in the referenced base.
Thus the same base message from the ApplicationMessage table can be
used by many different constraints, each of which defines a different
set of references for the substitution text placeholders in the message.
Example
The existing message number SL_100001 has the text "The &1
entered is not valid." You can reuse this message number and text
to construct a custom constraint error message.
- Specify an Object Name for
a SQL constraint, using the rules specified in the field description.
- Select an existing Message Text,
and the Message Number is displayed. For example, if you select the
Message Text "The &1 entered is not valid." the Message
Number SL_100001 is displayed.
- Specify a Message Description that describes how and when this
instance of the message is used. For example, "This message is
displayed when <state> is updated on an Applicant Reference
to a value that does not exist in any state."
- Specify the Message
Type. For any given Object Name, you can only have one Message
Type with the same value. For example, select Message Type 17 (Constraint
Message).
- Specify the Object Type. For
example, select 0 (Table Object).
- Specify the Message Severity.
- Save the record. If the type is 17 (Constraint Message) or 18 (Delete
Constraint), the Build Messages grid is enabled, where you can specify
this information:
- If the Message Text in the main grid has multiple substitution
expressions (&1, &2, etc.), add a row with a Sequence
Number corresponding to each of the substitution expressions.
- To reference the substitution text to use, either specify a
Message Number from the Maintain
Application Messages form or specify another existing Object
Name.
- A Message Number is always required. Specify MG_1
to indicate that the value in the Object Name field is to be used
to look up the substitution text. If the Message Number
is any value other than MG_1, then that value is used to look
up the message text on the Maintain
Application Messages form.
- If the Object Name field is used, select the appropriate value
from the drop-down list.
- The Message Text field displays the text that will be displayed
in place of the substitution expression.
- Save the record again.
- If your company uses source code control, click Generate
Message Script File. In the Generate
Application Messages Script form, specify the appropriate file
path and filter information, and click Generate
SQL Script File.
Related Topics
About Application Message
Construction