Auto add row to child bo when add row to parent bo


Author
Message
Attila Dobozi
Attila Dobozi
StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)
Group: Forum Members
Posts: 4, Visits: 14
I have three business objects on a maintenance form, Parent, Child, Grandchild.  The Child and Grandchild are both filled for the Parent.  The Grandchild contains all rows that belong to all Child rows for the current Parent.  The Child.ChildAutoFilterOption = MatchCurrentRow.

The Parent is tied to the MaintenanceToolstrip.  The Child is tied to a second, custom, toolstrip.
When Parent changes the Child and Grandchild are filled appropriately.  Navigation and editing work.

When adding a Child I want to also add a Grandchild.  In the custom toolstrip cmdAdd.Click() function I call Child.AddNew().  The Child.AfterAddNew() event calls GrandChild.Add().  When I trace into the GrandChild.SetDefaultValues() I see that the field values show the previous GrandChild row data instead of the new row data (the GrandChild pk is not -1).  It looks like I'm overwriting the previous GrandChild row's data with default values. 

There is a GrandChild_Navigated event on the form where I messagebox the Child and GrindChild pks.  The messagebox does not popup after the GrandChild.AddNew() or GrandChild.SetDefaultValues().  The messagebox pops once with Child.pk = -1 and GrandChild.pk = 88 (prev GrandChild.pk value) and immediately pops again with Child.pk=-1 and GrandChild.pk = -1. 

... a day later ...

Never mind.  If I call GrandChild.Add() in the cmdAdd.Click() after calling Child.Add() it works.  It looks like the Child_AfterAddNew() event occurs before the Child filter and GrandChild navigation occurs so GrandChild defaults are assigned to the wrong row.  So the lesson is don't call AddNew() on a child bo from the parent's AfterAddNew event.  I'm evaluating SF so couldn't trace into its source otherwise I would've figured this out sooner.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search