StrataFrame Forum

BO.Add doesn't FilterChildRecords

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

By Chan - 11/2/2008

Hi,

I found that, BOAdd() doesn't filter child record. Is it by design?

I also found that, previously BO.Add() will call navigate() method which will also FilterChildRecords. However, it is remarked and replace with ForceNavigatedAndBoundRefresh() which doesn't filterchildrecords.



Please advice. Personally, I think Add() should auto filterchildrecords as well.



Thank you
By Trent L. Taylor - 11/3/2008

Yes, by design.  If you look around the forum you will see that this has been a common topic in the past.  Generally from people having navigation issues because a filter is applied, a new record is added, and then the new record is not the current index.

The filter is respected on the add, but if you add a new record, you must set the columns that are part of the filter in order for the new record to show up where you expect it to be.  This is why we always recommend removing the filter prior to an add, set the columns that are part of the filter, then re-apply the filter.

By Chan - 11/3/2008

Hi,

I still not get it. Shall you explain in more details?

If I manually call FilterChildRecords() after call Add(), would it cause any issue?



Thank you
By Dustin Taylor - 11/5/2008

Trent's point is that things can get confusing when you try to add a record with a filter applied. His suggestion is to:

1) Remove the filter on the BO before adding a record. i.e. BusinessObject.Filter = ""

2) Add the record

3) Re-apply the filter after the record is saved. i.e. BusinessObject.Filter = "<Your filter here>"

If you then have a child filter record you need to re-apply, then yes, you would do it after the add. But when adding any child records, I would still recommend removing the filter from the child BOs before performing the add.

By Chan - 11/11/2008

Hi,

I think I used to face the problem whereby, the newly added child record, would be missing. it happens if AutoIncrement approach used to generate PK value. Is it the originally problem?



If so, Guid assignment in SetDefaultValues() should not cause the problem .. even though I call FilterCHildRecords() after ParentBO.Add(), am I right?



Thank you
By Trent L. Taylor - 11/12/2008

Is it the originally problem?

No.  And I will throw your next question in here as well, a GUID would not resolve the problem.  The problem is that if a filter is applied, let's say on a foreign key contraint, and a new record is added to the child BO, that new record will be immediately hidden the instant that it is created because of that filter.  This is just how ADO.NET views work.  So in order to get around this problem, remove the filter, add the child record and set the default values (i.e. the foreign key contraint column) and then reapply the filter and you will be OK.