Programmatically adding relationships to object instances
Hi!
I'm trying to insert a relationship from a parent object instance to a child object instnace programmatically. Ie, i want to do:
Do parentObject.childRefProperty.Insert(chilDobject)
where childRefProperty is defined by a string. I feel this should be achievable with $PROPERTY and/or $METHOD or maybe something in $SYSTEM.OBJ.*, but can't quite figure it out. Anyone know?
Cheers :)
Chris
Discussion (3)0
Comments
Have you tried...
set p=$property(parentObject,"childRefProperty")
do p.Insert(childObject)
do p.Insert(childObject)
Perfect, thanks! I'd actually already tried this but had some other bug in my code that meant me think it wasn't working - I looked more carefully and figured it out :)
I just tried the above out and it works.
You can do it more succinctly, but you must use "set" on $property as a "do" will throw a compile error for some reason...
set sc=$property(parentObject,"childRefProperty").Insert(childObject)