Hi.
I've added the following to my LiteCompanyCollection:
protected override object AddNewCore()
{
LiteCompany result;
result = LiteCompany.NewLiteCompany();
OnAddingNew(new AddingNewEventArgs(result));
Add(result);
return result;
}
And I'm adding a child to it like this:
LiteCompanyCollection
objLCC = LiteCompanyCollection.GetLiteCompanyCollection(-1); //Get all companies.The new child is added fine, however when I save it, DataPortal_Update() thinks the object I added IsNew is false, so the Update method is called instead of the Insert method. Am I supposed to be calling MarkNew() somewhere?
Thanks.
The last 2 lines of my DataPortal_Create are:
MarkNew()
ValidationRules.CheckRules()
So when you call .NewLiteCompany you should be using DataPortal_Create and it should be marking your child BO new.
I think the framework tries to do it for you automatically for root objects. I know Rocky moved the call to a couple of lines earlier in the code in 3.5 so I have to re-evaluate if I can now stop commenting it out. I was one of the few remaining coders who branched to DP_Create if the ID is not found in DP_Fetch and the BOs were getting mixed up with New and Old in earlier versions.
My templates have left the call to MarkNew and MarkOld even for root objects because I needed them set before calling check rules. I can re-evaluate them later too.
Joe
Thanks Joe.
Copyright (c) Marimer LLC