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.

  1. Specify an Object Name for a SQL constraint, using the rules specified in the field description.
  2. 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.
  3. 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."
  4. 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).  
  5. Specify the Object Type. For example, select 0 (Table Object).
  6. Specify the Message Severity.
  7. 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:
  8. Save the record again.
  9. 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