StrataFrame Forum

Object that could potentially have multiple parents.

http://forum.strataframe.net/Topic18424.aspx

By Geoff Hirst - 8/12/2008

Guys,

What is best practice for a scenario where you may have an object, that may have a different parent object depending on the form it is used in? For example, I have an object called parts. Parts can be called in my application to create a proposal (kind of sales order) of which I presently have 4 different types, they may also be used in invoicing, they may also be used in Jobs, where again parts may be used for maintenance purposes.

thanks in advance

Geoff Hirst

By Trent L. Taylor - 8/12/2008

If you are going to setup a relationship between the parent and the child, you may want to just manually use the RegisterForeignKey method.

bo.RegisterForeignKey(MyChildBO,"ChildFieldName")

When doing this, you can dynamically change the relationship between the parent BO and the child BO.  This does, however, have to be done in code and will require that you set the value of the child field when a new record is created.  But once that is done, all of the same functionality as using the ParentRelationship logic will still work, including the automatic update of child FK values if the parent is a new record, etc.

By Geoff Hirst - 8/12/2008

Trent,

Thanks for that chap, just what I needed.

Just another thing, should the naivgated event fire after a seektoprimarykey? Doesn't seem to be doing for me.

thanks for the help.

G.

By Dustin Taylor - 8/12/2008

The Navigated event won't fire after a seektoprimary key since a seek doesn't update the bound controls (which is the difference between "navigate" and "move".) The seek method will return True or False based on whether it is successfull, so you could test on that and fire off whatever code you needed to in the same code block.

If you do want to update the UI, however, you can use the NavigateToPrimaryKey, which will fire the Navigated event upon completion Smile.