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):
$PROPERTIES
Case CURPRO
When “STARTDATE” : Gosub STARTDATE
Endcase
Return
$STARTDATE
Case ACTION
When “PROPAGATE”
Gosub VALIDATE_STARTDATE
Endcase
Return
$VALIDATE_STARTDATE
If this.ENDDATE <> AVOID.ADATE & this.STARTDATE > this.ENDDATE
ASTATUS = fmet this.ASETERROR(“STARTDATE”, “Start date cannot be after End date”, [V]CST_AERROR)
Endif
Return
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:
$PROPERTIES
Case CURPRO
When “STARTDATE” : Gosub STARTDATE
When “ENDDATE” : Gosub ENDDATE
Endcase
Return
$STARTDATE
Case ACTION
When “PROPAGATE”
Gosub VALIDATE_STARTDATE
Endcase
Return
$ENDDATE
Case ACTION
When “PROPAGATE”
Gosub VALIDATE_ENDDATE
Endcase
Return
$VALIDATE_STARTDATE
If this.ENDDATE <> AVOID.ADATE & this.STARTDATE > this.ENDDATE`
ASTATUS = fmet this.ASETERROR(“STARTDATE”, “Start date cannot be after End date”, [V]CST_AERROR)
Endif
Return
$VALIDATE_ENDDATE
If this.ENDDATE <> AVOID.ADATE & this.ENDDATE < this.STARTDATE
ASTATUS = fmet this.ASETERROR(“ENDDATE”, “End date cannot be before Start date”, [V]CST_AERROR)
Endif
Return
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_DATES
If CURPRO = “STARTDATE”
ASTATUS = fmet this.ADELETEERROR(“ENDDATE”)
Else
ASTATUS = fmet this.ADELETEERROR(“STARTDATE”)
Endif
If this.ENDDATE <> AVOID.ADATE & this.STARTDATE > this.ENDDATE
If CURPRO = “STARTDATE”
ASTATUS = fmet this.ASETERROR(“STARTDATE”, “Start date cannot be after End date”, [V]CST_AERROR)
Else
ASTATUS = fmet this.ASETERROR(“ENDDATE”, “End date cannot be before Start date”, [V]CST_AERROR)
Endif
Endif
Return
$VALIDATE_STARTDATE
ASTATUS = fmet this.ADELETEERROR(“ENDDATE”)
If this.ENDDATE <> AVOID.ADATE & this.STARTDATE > this.ENDDATE
ASTATUS = fmet this.ASETERROR(“STARTDATE”, “Start date cannot be after End date”, [V]CST_AERROR)
Endif
Return
$VALIDATE_ENDDATE
ASTATUS = fmet this.ADELETEERROR(“STARTDATE”)
If this.ENDDATE <> AVOID.ADATE & this.ENDDATE < this.STARTDATE
ASTATUS = fmet this.ASETERROR(“ENDDATE”, “End date cannot be before Start date”, [V]CST_AERROR)
Endif
Return
Note: Hard-coded message strings should be replaced with mess( ) calls.