Handling Errors on Interdependent Fields

This document provides information on how to handle errors on two or more interdependent fields (for example, a start and end date range).

When you click a particular field, the Supervisor cleans up errors assigned to it. For example, for the Start date field, the following code makes sure that the value of Start date is not greater than the value of End date (if End date is not blank):

 $PROPERTIESCase CURPROWhen “STARTDATE” : Gosub STARTDATEEndcaseReturn$STARTDATECase ACTIONWhen “PROPAGATE”Gosub VALIDATE_STARTDATEEndcaseReturn$VALIDATE_STARTDATEIf this.ENDDATE <> AVOID.ADATE & this.STARTDATE > this.ENDDATEASTATUS = fmet this.ASETERROR(“STARTDATE”, “Start date cannot be after End date”, [V]CST_AERROR)EndifReturn

If an invalid start date is entered, error “Start date cannot be after End date” is displayed, attached to the Start date field. If a valid start date is then entered, the error is cleared by the Supervisor.

Note: If you implement validation on the start date’s PROPAGATE event, the validation will not be executed again when clicking Save.

A similar validation can be applied to the End date field:

 $PROPERTIESCase CURPROWhen “STARTDATE” : Gosub STARTDATEWhen “ENDDATE” : Gosub ENDDATEEndcaseReturn$STARTDATECase ACTIONWhen “PROPAGATE”Gosub VALIDATE_STARTDATEEndcaseReturn$ENDDATECase ACTIONWhen “PROPAGATE”Gosub VALIDATE_ENDDATEEndcaseReturn$VALIDATE_STARTDATEIf this.ENDDATE <> AVOID.ADATE & this.STARTDATE > this.ENDDATE`ASTATUS = fmet this.ASETERROR(“STARTDATE”, “Start date cannot be after End date”, [V]CST_AERROR)EndifReturn$VALIDATE_ENDDATEIf this.ENDDATE <> AVOID.ADATE & this.ENDDATE < this.STARTDATEASTATUS = fmet this.ASETERROR(“ENDDATE”, “End date cannot be before Start date”, [V]CST_AERROR)EndifReturn

If an invalid end date is entered, error “End date cannot be before Start date” is displayed, attached to the End date field. If a valid End date is then entered, the error is cleared by the Supervisor.

However, if you try to correct the date range error by adjusting the start date, the previous error (assigned to End date) is not cleared by the Supervisor, even though the date range is now valid, and no new error is displayed. This is due to the fact that the Start date field is now selected.

To clear the previous error in this scenario, method "ADELETEERROR" must be manually called to clear any errors on the alternate field:

 $VALIDATE_DATESIf CURPRO = “STARTDATE”ASTATUS = fmet this.ADELETEERROR(“ENDDATE”)ElseASTATUS = fmet this.ADELETEERROR(“STARTDATE”)EndifIf this.ENDDATE <> AVOID.ADATE & this.STARTDATE > this.ENDDATEIf CURPRO = “STARTDATE”ASTATUS = fmet this.ASETERROR(“STARTDATE”, “Start date cannot be after End date”, [V]CST_AERROR)ElseASTATUS = fmet this.ASETERROR(“ENDDATE”, “End date cannot be before Start date”, [V]CST_AERROR)EndifEndifReturn$VALIDATE_STARTDATEASTATUS = fmet this.ADELETEERROR(“ENDDATE”)If this.ENDDATE <> AVOID.ADATE & this.STARTDATE > this.ENDDATEASTATUS = fmet this.ASETERROR(“STARTDATE”, “Start date cannot be after End date”, [V]CST_AERROR)EndifReturn$VALIDATE_ENDDATEASTATUS = fmet this.ADELETEERROR(“STARTDATE”)If this.ENDDATE <> AVOID.ADATE & this.ENDDATE < this.STARTDATEASTATUS = fmet this.ASETERROR(“ENDDATE”, “End date cannot be before Start date”, [V]CST_AERROR)EndifReturn

Note: Hard-coded message strings should be replaced with mess( ) calls.