How to process child collection rows
This ‘How-to’ provides information on how to process rows in a child collection.
The following development process demonstrates how to set an attribute of a property on all the rows in a child class.
Code to process rows in a child collection should go under the 'CURPTH' class path for the corresponding child collection, rather than under the main class. For example:
If the class path is the child class (CURPTH = "[child class]"), the supervisor executes these events once per collection row:
$METHODSCase CURPTHWhen "[child class]"Case ACTIONWhen "AREAD_AFTER"Gosub ACTIVATE_FIELDSEndcaseEndcaseReturn
$ACTIVATE_FIELDSASTATUS = fmet this.ASETATTRIBUTE("PROPERTY",...Return
If the class path is the main class (CURPTH = "" for example, blank = main class), the code is complex. The supervisor executes these events once for the entire entity:
$METHODSCase CURPTHWhen ""Case ACTIONWhen "AREAD_AFTER"Gosub ACTIVATE_FIELDSEndcaseEndcaseReturn
$ACTIVATE_FIELDSFor I = 1 To maxtab(this.CHILD)If this.CHILD(I)<>null and find(this.ASTALIN,[V]CST_ADEL,[V]CST_ANEWDEL)=0 ASTATUS = fmet this.CHILD(I).ASETATTRIBUTE("PROPERTY",...EndifNextReturn
It is recommended to use the first method to avoid unnecessary loops and avoid dealing with indexes in a collection.