ONERROR

Use ONERROR in component rules to add user-defined error messages to the data section of the audit log.

The ONERROR function adds a user-defined error message to the data section of the audit log. This function is relevant only in Type Designer Component rules.

.

Syntax:
ONERROR (single-condition-expression , single-text-expression)
Meaning:
ONERROR (condition_to_evaluate , message_to_display)
Returns:
"True" or "false"

If condition_to_evaluate evaluates to "true", the function returns "true".

If condition_to_evaluate evaluates to "false", the function returns "false".

If data audit is enabled and the object to which the component rule applies will result in a failed component rule message (status E09), message_to_display is written to the data audit section of the audit log with an entry type of U, representing user-defined.

If the failed component rule message (E09) appears in the data section of the audit log, one or more user-defined error messages can also be included in the data section of the audit log. If a component rule has one ONERROR function, one user-defined error message or none is included in the audit log. If a component rule has two ONERROR functions, two user-defined error messages at most are included in the audit log, and so on.

Examples

  • Here is a component rule without ONERROR:

    Claim Date Field > Accident Date Field &

    Claim Date Field < ADDDAYS (Accident Date Field, 365)

    If the component rule fails, the data section of the audit log shows the following information:

    <DataLog>
    <input card="1">
     <object      ...      status="E07">InsuranceClaim</object>
     <object      ...      status="E09">Claim Date Field</object>
                                        <Text>980725</Text>
     <object      ...      status="E07">InsuranceClaim</object>
     <object      ...      status="E09">Claim Date Field</object>
                                        <Text>990526</Text>
    </input>
    </DataLog>
    

Status code E09 for the Claim Date Field indicates that the data for that object failed its component rule, but does not provide any further detail.

  • Using ONERROR, one or more error messages can be added to the data section of the audit log to provide more information as to how or why the component rule failed. For example,

    ONERROR ( Claim Date Field > Accident Date Field , "Claim date before accident." ) &

    ONERROR ( Claim Date Field < ADDDAYS ( Accident Date Field , 365 ) , "Claim is more than one year old." )

    If the component rule fails and ONERROR is used, the data section of the audit log can show the following messages:

    <DataLog>
    <input card="1">
     <object  ...  status="E07">InsuranceClaim</object>
     <object  ...  status="E09">Claim Date Field</object>
                                <Text>980725</Text>
                                <User>Claim date before accident.</User>
     <object  ...  status="E07">InsuranceClaim</object>
     <object  ...  status="E09">Claim Date Field</object>
                                <Text>990526</Text>
                                <User>Claim is more than one year old.</User>
    </input>
    </DataLog>