KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Remove all attributes from child object to guarantee removal of all references
PRODUCT: 4D | VERSION: 17 | PLATFORM: Mac & Win
Published On: March 20, 2019

When trying to remove all references to a child object within a parent object, one mistake is to remove the parent attribute and assume child object is also removed. Take the example below:

C_OBJECT($parent_o;$child_o)
$child_o:=New object("first_name";"Bobby";"last_name";"Bo")
$parent_o:=New object("child";$child_o) // $parent_o.child is a new reference to $child_o




If the child attribute is removed using OB REMOVE($parent_o;"child") or $parent_o.child:=Null, $child_o will still retain its reference.





In order to successfully remove an object and all of its references, you must remove all of the attributes from the child like shown below:

C_TEXT($attr_t)
For each ($attr_t;$parent_o.child)
   OB REMOVE($parent_o.child;$attr_t)
End for each