Dear Tamara,
Your observation is right with respect to the "BeforeDeleteInstance" event in ADOxx. The CONNECTORS are discarded before the event actually fires. In order to realize your scenario we would propose the following implementation approach:
1. Additional attribute of Type EXPRESSION in (all) classes that can be used as SOURCE instances for relationsThis attribute takes care to store automatically all connected instance IDs within the SOURCE instance. The attribute must not be made visible to the user (excluded from AttrRep)
Attributename: ConnectedObjs
1EXPR type:string expr:fixed: (ctobjs("hat"))
HINT: in the example above, the EXPRESSION only considers the "hat" relation class. Multiple relation classes can be combined using the tokunion() to combine tokens.
2. Update des EVENT AdoScriptFor simplicity reasons, the fragment below only choose the logic proposed to delete connected objects.
1ON_EVENT "BeforeDeleteInstance" {
2 #...
3 # Before delete, read the value of the StringToken in ConnectedObjs
4 CC "Core" debug GET_ATTR_VAL objid: (instid) attrname"ConnectedObjs")
5 # Check whether the attribute exists and only continue if it exisits.
6 IF (ecode = 0) {
7 SETL ltObjIDsval)
8 # Delete connected objects - TODO: Filter target classes by classid/type, "stObjID" within the loop can be used to retrieve properties of the instance.
9 FOR stObjID inltObjIDs) {
10 # implicit recursion of event - DELETE_OBJ triggers another "BeforeDeleteInstance" - TODO check on self-referencing instances
11 CC "Core" DELETE_OBJ modelid: (modelid) objid: (VAL stObjID)
12 }
13 }
14}