StrataFrame Forum

Add record from ListView using a ChildForm

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

By Juan Carlos Pazos - 4/7/2009

Hi

I will try to explain this the more simple that I can:

I have a ListView that has a BO named PublicationsBO, the ListView has the usual Add, Edit, Delete buttons. I can add and edit records without problem using the ChildFormDialog.

The ChildForm has also a ListView that has ProductsForPublicationsBO, the relationships are setup and configured, I add a record manually and I can view in List and edit that record using another ChildFormDialog.

My problem is that if I add a new record to the ProductsForPublicationsBO the ParentKey field is not added -remains in 0 - so, this record is not realted to any Publication

In this same app, I use relationships, ChildFormDialogs but in all previous cases that dialogs are called from an MaintenanceForm, not from a ListView form - ChildForm. In all of those, the Parentkey is added by SF without problems.

Can you tell me how to add a new child correctly from a ChildForm?

Maybe StrataFlix does this, but I can not follow that sample because almost is done by code, and I'm not so good trying to addapt the ideas there.

Regards 

By Edhy Rijo - 4/8/2009

Hi Juan Carlos,



In the help file search by "RegisterForeignKey", then take a look at the topic "Defining a Relationship Between Business Objects".

Probably you will need to manually assign the FK using the BO.RegisterForeingKey() method.
By Trent L. Taylor - 4/8/2009

Juan,

This could be due to the translations AFTER the BOs translated.  For grins, override the Onload of the child form.  After the MyBase.OnLoad() call, reset the instances of the relationship and I bet it will resolve your error.  The issue could be that the relationship is still referencing the original instance instead of the translated instance.

MyBase.OnLoad()
MyChildBo.ParentBusinessObject = MyparentBo
By Juan Carlos Pazos - 4/8/2009

Hi Trent

override the Onload of the child form

How do I override the onload? I never done this before.

Regards

By Edhy Rijo - 4/8/2009

Juan Carlos Pazos (04/08/2009)
Hi Trent



override the Onload of the child form




How do I override the onload? I never done this before.



Regards


Hi Juan Carlos

Just start typing overrides, follow Intellisense and choose the method you want to override, in this case the OnLoad().
By Juan Carlos Pazos - 4/8/2009

Edhy

Thanks, I add this and works:

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)

MyBase.OnLoad(e)

PublicacionesProductosBO1.ParentBusinessObject = PublicacionesBO1

End Sub

Regards