Rule and messages: Example 1

In the following example, the rule prevents users from logging more than a total of 20 hours on Misc items in a time sheet. This rule uses the [TMG.TIME_SHEET_ID]token and it evaluates effort entered by users on time sheet lines.

<rule> <identifier>misc_excess_hours</identifier> <title>misc.excessHours.title</title> <enabled>true</enabled> <sql><![CDATA[ SELECT 1 FROM tm_time_sheets ts, tm_time_sheet_lines tsl, tm_actuals ta, tm_actuals_effort tae WHERE ts.time_sheet_id = tsl.time_sheet_id AND tsl.time_sheet_line_id = ta.time_sheet_line_id AND ta.actuals_id = tae.actuals_id AND ta.totals_flag = 'Y' AND tsl.work_item_type = 'MISC' AND ts.time_sheet_id = [TMG.TIME_SHEET_ID] HAVING SUM (tae.actual_effort) > 20 ]]></sql> <violation>misc.excessHours.violation</violation> <error>genericError</error> </rule>

Assume this rule uses the following key-value pairs in the properties file:

misc.excessHours.title=Excess Hours

misc.excessHours.violation=This time sheet exceeds the maximum of 20 hours permitted for the sum of all Misc. lines.

    genericError=An error occurred while checking this time sheet rule.

Based on the SQL and the properties file, if a user submits a time sheet with too many hours for Misc items, a Non-Compliance message is displayed with the following title and text:

Excess Hours This time sheet exceeds the maximum of 20 hours permitted for the sum of all Misc. lines.

Based on the SQL and the properties file, if a runtime error occurs during execution of the SQL, the error message that appears consists of the message title specified in the properties file, followed by the generic error message text:

Excess Hours An error occurred while checking this time sheet rule