StrataFrame Forum

Problem with Saving Child Records

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

By Geoff Hirst - 5/25/2009

Guys,

I have been chasing this most of the day and although some success I am really puzzled by what I have going on now.

I am using the automated listview tools, and as such have a parentBO, childBO and childformdialog . I have read many previous posts and removed my childautofilter that was causing some issues.

I am passing both my parent and child BO's through to the childform using translations that are configured on the childformdialog. However, in my childform I have overriden the onload event, as described in a another post, to set the parentbusinessobject of my childBO as for some reason it doesn't come over from the parentform.

If I add a new parent record, then go on to add a number of childrecords, save each child, then return to the parent and save the parent, my understanding is that the child records should recieve the parents ID upon the parent saving, is this correct? What I have happening is that the first child record I entered, does not get the parents key, but subsequent ones do.

If I add a childrecord to a parent that has already been saved, then again, the first one doesn't get the foreignkey, the second one does.

Like I say, chased this one most of the day just can't see what I am doing that's wrong.

thanks

Geoff.

By Edhy Rijo - 5/25/2009

Geoff Hirst (05/25/2009)


If I add a new parent record, then go on to add a number of childrecords, save each child, then return to the parent and save the parent, my understanding is that the child records should receive the parents ID upon the parent saving, is this correct?.




Well, if the relationship is setup properly, by saving the child, it will automatically trigger a save in the parent record so a proper PK will be assign to the children records. At this point it will be easier if you provide a quick sample using the SF sample data with all your relations. I posted one a couple of days ago here http://forum.strataframe.net/FindPost23154.aspx it is in C# but it is pretty simple, also in that thread I did a quick explanation on this very issue.
By Trent L. Taylor - 5/26/2009

It sounds like your reference is not updated. When you say that you overwrote the OnLoad, what does your code look like? You need to call the base logic first, then reset the object reference on the list. Something like this:



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

MyBase.OnLoad(e)



MyList.BusinessObject = MyBo

End Sub