Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best way to add child records in code
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
VB.NET 1.1
Database:
MS SQL Server
Miscellaneous
Thread ID:
01001895
Message ID:
01001900
Views:
16
I haven't done this before, but looking at the Developer's Guide, you can add the 5 child records by setting the DocItem's AutoNewOnParentAdded property to False, then putting code in the DocItem's HookParentAdded() method. You also have to register DocItem as a child business object of DocHead in the form's constructor in order for the HookParentMethod() to be called.

>Hi All,
>
>I'm new to MM and am trying to add some child records in code within a business object each time a new parent record is created. As I create the child records, I'd like to be able to make use of all the MM capabilities (business rule testing, error trapping, primary key / foreign key handling, etc.) and would appreciate a "best practices" recommendation for how to do this within MM.
>
>I have two tables (at this point managed by two business objects): DocHead (parent) and DocItem (child). These both have autoincrement PKs (DocHeadID and DocItemPK) and they should always have a one-to-many relationship based on DocHead.DocHeadID = DocItem.DocHeadID.
>
>Each time the user creates a new DocHead record, I'd like it's business object to also create 5 related DocItem records and return all of these new records to the form for editing.
>
>Thanks in advance,
Chris McCandless
Red Sky Software
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform