Grandchild BO does not get foreign key value from Parent Insert


Author
Message
Leonard P.
Leonard P.
StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)
Group: Awaiting Activation
Posts: 65, Visits: 306
Hello,



I have a situation where I need to insert new rows of 3 related BOs on .Save. BOs parent/child relationship is setup correctly in the BO Mapper, and it follows the following path:



BO_1

P1_Key (PK)



BO_2 (Child to BO_1)

P2_Key (PK)

P1_Key (FK to BO_1)



BO_3 (Child to BO_2)

P3_Key (PK)

P1_Key (FK to BO_2)

P2_Key (FK to BO_2)



When I call Save to add new rows of all 3 BOs, the first 2 inserts complete successfully, but BO_3 insert fails, because it doesn't get newly inserted P1_Key. I realize that the design could be improved by simply getting rid of P1_Key FK in BO_3, but lets say for now that I need to stick to this design to accommodate some obscure requirements.

So, why doesn't BO_3 get P1_Key?



Thanks



Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
I'm sure you'll get replies with a lot more SF knowledge than mine, but my first reaction would be I wouldn't expect bo3 to get the pk from bo1 automatically, since the parentchild relationship is only between bo2 and bo3. If you are getting bo2's pk as an fk in bo3 I'd say everything is working as designed. You might want to grab the bo1fk from bo2 on the save of bo3, but I dont think the framework is going to give you two fks.



Alex Luyando
Alex Luyando
StrataFrame User (210 reputation)StrataFrame User (210 reputation)StrataFrame User (210 reputation)StrataFrame User (210 reputation)StrataFrame User (210 reputation)StrataFrame User (210 reputation)StrataFrame User (210 reputation)StrataFrame User (210 reputation)StrataFrame User (210 reputation)
Group: StrataFrame Users
Posts: 112, Visits: 1.2K
Hi all -



Does anyone know if the use of RegisterForeignKey() would be a solution to this problem?

________________
_____/ Regards,
____/ al
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Yes, the RegisterForeignKey method would be a great option here.  The RegisterForeignKey method allows you to create as many foreign relationships as you need to any one (or multiple) BOs.  This is the purpose for this method.  The only difference from the single ParentBusinessobject funtionality is that when you adda  new record, you must set the foreign key field's value (even if it is a new negative PK value) and then the RegisterForeignKey logic will handle everything else from there.  Just to illustrate my point:

MyParentBO.ForeignKeyField = MyInitialValue

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