This document provides information on how to use a standard method to change the properties (fields) of a data class from another data class.
The development process described below demonstrates how to add a simple script to a data class (MYCLASS2) to update the properties (MYPROP1) of a different data class (MYCLASS1).
$PROPERTIES and $METHODS labels are called in the event. You can also manually enter the running order.# Structure MYCLASS2
##########################################
# METHODS #
##########################################
$METHODS
Case CURPTH
When ""
Case ACTION
When "AINSERT_AFTER" Gosub AINSERT_AFTER # Update after insert
Endcase
Endcase
Return
# Update properties in MYCLASS1 using MYCLASS2
$AINSERT_AFTER
# Declaration new instance of MYCLASS1 data class
Local Instance MYCLASS Using C_MYCLASS1
MYCLASS = NewInstance C_MYCLASS1 AllocGroup Null
ASTATUS=fmet MYCLASS.AREAD(this.KEY_VALUE)
If ASTATUS<>[V]CST_AOK
ASTATUS = fmet THIS.ASETERROR ("", "Not updated.", [V]CST_AERROR)
ARET_VALUE= CST_AFALSE
Else
# change property values and update
MYCLASS.MYPROP1 = this.MYPROP2
ASTATUS=fmet MYCLASS.AUPDATE
If ASTATUS<>[V]CST_AOK
ASTATUS = fmet THIS.ASETERROR ("", "Not updated.", [V]CST_AERROR)
ARET_VALUE= CST_AFALSE
Else
ARET_VALUE= CST_ATRUE
Endif
Endif
# Free instances
FreeGroup MYCLASS
Return