How to use multiple aseterror methods in a single representation class
This ‘How-to’ provides information on how to use multiple ASETERROR methods in a single representation class.
The following development process demonstrates how to prevent the result returned from an ASETERROR call from being overwritten by a subsequent ASETERROR call when multiple ASETERROR methods are used in a single representation class.
The result returned from an ASETERROR call can be overridden by subsequent ASETERROR calls when multiple ASETERROR methods are used in a single representation class, if the result of each ASETERROR is not checked before control is returned to the supervisor and the ASTATUS actioned.
CODECODE CODE`$METHODSCase CURPTHWhen ""Case ACTIONWhen "AINSERT_CONTROL_AFTER"Gosub VALIDATEEndcaseEndcaseReturn# -------------------------------$VALIDATEIf (ASTATUS = CST_AOK)Gosub VALIDATE_PROPERTY1EndifIf (ASTATUS = CST_AOK)Gosub VALIDATE_PROPERTY2EndifReturn````Example 2 – Override a possibility
CODECODE CODE`$METHODSCase CURPTH
When ""
Case ACTION
When "AINSERT_CONTROL_AFTER"
Gosub VALIDATE_PROPERTY1
Gosub VALIDATE_PROPERTY2
Endcase
Endcase
Return
ha$h -------------------------------
$VALIDATE_PROPERTY1
…
ASTATUS = fmet this.ASETERROR("",
Return
$VALIDATE_PROPERTY2
…
ASTATUS = fmet this.ASETERROR("",
Return
````
In this example:
* If the validation of the first property (PROPERTY1) fails, the error message is displayed and ASTATUS is set to CST_AERROR.
* If the validation of the second property (PROPERTY2) succeeds, no error is displayed and ASTATUS is then set to CST_AOK.
* The error on PROPERTY1 will not prevent the record from being saved to the database.