How to instantiate Child Object


Author
Message
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
I have the following code in my Parent BusinessObject Vlaidation  to ensure that at least one Child is entered.... works fine from my main Parent/Child data entry form

ChildBO myChildBO = (ChildBO)this.ChildBusinessObjects[0];

if (myChildBO.Count <= 0)  { this.AddBrokenRule(this.ITR_CUSREF, "There must be at least one Detail Line"); }

 

Now , on a different form, where I am updating just one field from the Parent Business object, the MyParent.Save() gives an index error, probably because the Child BO is not instantiated. On this partcular form , the Child BI is not used at all.

How do I 'Instantiate' and populate the child Business Object in Code , so that the error does not happen

(I have tried the folloiwng code, but not quite sure what it does...got from another thread)

 

BusinessParentRelationship myRel = new BusinessParentRelationship();
myRel.ForeignKeyField = new string[] { "IDE_ITRPK" };
myRel.ParentPrimaryKeyField = new string[] {"ITR_PK"};
myRel.ParentBusinessObjectType = "ITR";
ChildBO1.ParentRelationship = myRel;
ChildBO1.IdeFillByItrpk(itrBO1.ITR_PK);

 

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search