Where does the parent's index get assigned?


Author
Message
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
I am working through various issues with the ChildFormDialog process.  I have duplicated the code that I found in the CRM sample app.  I don't think I missed anything.  The edit process had me stumped until I realized that I was filling the wrong BO with the detail data (silly me Wink ).  Now, I am having trouble with the add process.  When the add button is clicked, the child form is sent a boolean parameter of true which tells the child form to create a new detail item.  On the detail form there is no hint of the parent BO so no parent index is floating around anywhere.  I cannot assign the parent index before or after the dialog because the timing would be off (I think).  When do I assign that parent index to the child record?

Thanks!
Bill

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
If you need to assign any values to a new record that is created by the child form, your best bet would be to pass them over in the constructor of the child dialog, save them off in private fields, and then in the ParentFormLoading event of the business object, set the values. 

However, if you're looking to set the FK on the field, then you should be able to define the relationship on the parent form and not worry about it again, because the child form uses the same business object reference as the parent form, so the bo on the child form will already be aware of its parent business object.

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
I thought about passing the index in the constructor.  So far, that looks like the best way to go.

I checked my BOs on the parent form.  They are setup as parent-child.  I am not sure what else I would need to do in order to make this relationship stick on the child dialog, though.  After a quick scan of the properties on the child BO, I noticed that ChildAutoFilterOption is set to 'Off'...should it be 'MatchCurrentRow'?

Btw, thanks for the speedy response!  Amazing!!
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
This is the error I get, even if I turn that property on:

BusinessLayerException
  An error occurred while saving an the data to the server.
DataLayerSavingException
  INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'FK_SalesOrderDetails_SalesOrderMaster'. The conflict occurred in database 'ASPire', table 'SalesOrderMaster', column 'orderindex'.

The statement has been terminated.
SqlException
  INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'FK_SalesOrderDetails_SalesOrderMaster'. The conflict occurred in database 'ASPire', table 'SalesOrderMaster', column 'orderindex'.

The statement has been terminated.

---

I attached a snapshot of the relationship in the DB.  Perhaps there is something awry there.

Thanks!
Bill

Attachments
RelProp.JPG (100 views, 39.00 KB)
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
I went with the passing-the-index-to-the-constructor method.  That works.  It was easy to implement; however, if there is a StrataFrame way to do this, then I would really like to get that to work.  Any more feedback on the parent-child BO relationship setup would be great.

Thanks for all of the help!
Bill

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Looking at that snapshot, is what is the value of the foreign key before you call Save() on the business object?  If you setup the relationship and allow the business objects to maintain it, then the auto-assigned values will be passed to the child's foreign key when the parent is saved (i.e.: if the parent has a new row and you add a new child row before saving the parent, then the foreign key will be a negative number, which is replaced with a positive number when you save the parent (it passes it down to the known children)).  If you don't setup the relationship and you have a new, unsaved parent row, then you will need to use the GetPostSavePrimaryKeyValue() on the parent to retrieve the correct FK value before saving the child.
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
The parent already exists.

I will be setting up another ChildDialog arrangement either today or Monday.  I will try again to see if the parent and child will get along the StrataFrame way.  Otherwise, I will resort to the passing of the index to the constructor of the child dialog form.

Thanks for your help!
Bill

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