Parent - Child BO and Trying to Update Child


Author
Message
Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
Interesting. I moved the save() into the loop and it worked. Is that because the child table has been filtered with the parent child relationship and needs to get saved before the next filter? When it comes out of the loop would the child table be filtered and that is why I only got one record saved? I am looking to understand this.



Thanks again for all of the help.
Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Terry,



You have to be very careful when using the BO.Filter since it may get you the wrong data.



If you have your relationship setup correctly, then you don't have to use the BO.Filter. If possible please post the whole code so we can have a better look at what you are doing. Saving the record inside the loop may not be the best approach based on how you are setting the whole scenario.

Edhy Rijo

Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
Sorry I have been so late on this but I have been working on another issue and finally resolved it.



Edhy this is all the code. Just in the click of a button and the parent child relationship set up on the form. If I move the Save inside the loop the data gets saved. If I move it out side the loop only the last data gets saved. When I was talking about filtering I was referring to SF's automatic filtering of the child records not me filtering anything.





If EventEntriesRodeoBO1.MoveFirst Then

For Each loRodeo As EventEntriesRodeoBO In Me.EventEntriesRodeoBO1.GetEnumerable



Select Case loRodeo.eventCD

Case "BB"

ContestantsRodeoBO1.EventBB = loRodeo.eventCD

Case "BR"

ContestantsRodeoBO1.EventBR = loRodeo.eventCD

Case "GB"

ContestantsRodeoBO1.EventGB = loRodeo.eventCD

Case "RB"

ContestantsRodeoBO1.EventRB = loRodeo.eventCD

Case "SR"

ContestantsRodeoBO1.EventSR = loRodeo.eventCD

Case "SW"

ContestantsRodeoBO1.EventSW = loRodeo.eventCD

Case "TD"

ContestantsRodeoBO1.EventTD = loRodeo.eventCD

Case "TR"

ContestantsRodeoBO1.EventTR = loRodeo.eventCD

End Select



' ContestantsRodeoBO1.Save()

Next

End If



' ContestantsRodeoBO1.Save()



Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
As a follow up. Unless I put the following code after the For each lorodeo



Me.ContestantsRodeoBO1.FillByParentPrimaryKey(loRodeo.contestantId)



Nothing gets updated at all no matter where I put the save. Does that mean my parent child is not working? It does work on the form with the toolstrip.
Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Well it is not going to be easy to figure out without a sample, but the Me.EventEntriesRodeoBO1 BO should have been already filled and filtered using Me.ContestantsRodeoBO1.FillByParentPrimaryKey(loRodeo.contestantId) but again, that should not affect the FOR loop since.



Just to be clear, the child BO Me.EventEntriesRodeoBO1 should already have all the records related to the parent before going to the FOR loop. I usually put the FillByParentprimaryKey() in the Navigated event of the parent BO.



If still does not work, see if you can build a quick sample using the SF sample database. I have done that many times and in a more difficult way using the BO.Filter() which is very powerful and dangerous if you are not focus. BigGrin

Edhy Rijo

Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
This Child BO is the ContestantsRodeoBO and the parent is the EventEntriesRodeoBO.



I was trying to put the Me.ContestantsRodeoBO1.FillByParentPrimaryKey(loRodeo.contestantId) in the navigated of the EventEntriesRodeoBO but of course it knows nothing about the object loRodeo. I tried a couple of other combinations but can not seem to get how to get all the references correct.

This was the last try but not working? Remember the parent is Event.... and the child is contestant......





Private Sub EventEntriesRodeoBO_Navigated(ByVal e As MicroFour.StrataFrame.Business.NavigatedEventArgs) Handles MyBase.Navigated

ContestantsRodeoBO.FillByParentPrimaryKey(Me.contestantId)

End Sub





Thanks for any help.
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Here's what I would do (C#, sorry):





foreach (EventEntriesRoderBO loRodeo in EventEntriesRodeoBO1.GetEnumerable())

{

. ContestantsRodeoBO loContestants = new ContestantsRodeoBO();

. loContestants.FillByParentPrimaryKey(loRodeo.contestantID);

. if (loContestants.Count > 0)

. {

. loContestants.Edit(); 'per Edhy, this is not necessary...just showing it for clarity

. switch (loRodeo.eventCD)

. {

. case "BB":

. loContestants.EventBB = loRodeo.eventCD;

. break;

. case ...

. }

. loContestants.Save();

. }

}





I find it a lot easier to manually handle the filling of child BOs. I often get lost in the automated attempts to do so.



Hope this helps,

Bill
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
If anyone knows how to get the code spacing/indentation to work properly, please let me know. I tried placing a period at the beginning of each line, but all of the spacing following it was whacked. Sorry for the poor indentation. Hope you can still read it.
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I just use html non-breaking space code: ampersand nbsp;



Be sure to copy the content as these are removed if you preview the post.



I'd love to know if there is an easier way.
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
This is what I do:

I usually just edit the code in a .txt file with Notepad

    Than I copy it from there to the browser

        If I want to copy code from VS
        I copy it to the .txt file too first
        And then copy it from there to the browser

    And this usually works fine
   
Hope it helps


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