﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Grandchild BO does not get foreign key value from Parent Insert</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Sat, 04 Jul 2026 07:46:48 GMT</lastBuildDate><ttl>20</ttl><item><title>Grandchild BO does not get foreign key value from Parent Insert</title><link>http://forum.strataframe.net/FindPost21239.aspx</link><description>Hello,&lt;br&gt;
&lt;br&gt;
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:&lt;br&gt;
&lt;br&gt;
BO_1&lt;br&gt;
  P1_Key (PK)&lt;br&gt;
&lt;br&gt;
BO_2 (Child to BO_1)&lt;br&gt;
  P2_Key (PK)&lt;br&gt;
  P1_Key (FK to BO_1)&lt;br&gt;
&lt;br&gt;
BO_3 (Child to BO_2)&lt;br&gt;
 P3_Key (PK)&lt;br&gt;
 P1_Key (FK to BO_2)&lt;br&gt;
 P2_Key (FK to BO_2)&lt;br&gt;
&lt;br&gt;
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. &lt;br&gt;
So, why doesn't BO_3 get P1_Key?&lt;br&gt;
&lt;br&gt;
Thanks&lt;br&gt;
&lt;br&gt;</description><pubDate>Wed, 17 Dec 2008 09:08:59 GMT</pubDate><dc:creator>Leonard P.</dc:creator></item><item><title>RE: Grandchild BO does not get foreign key value from Parent Insert</title><link>http://forum.strataframe.net/FindPost21249.aspx</link><description>Yes, the RegisterForeignKey method would be a great option here.&amp;nbsp; The RegisterForeignKey method allows you to create as many foreign relationships as you need to any one (or multiple) BOs.&amp;nbsp; This is the purpose for this method.&amp;nbsp; The only difference from the single ParentBusinessobject funtionality is that when you adda&amp;nbsp; 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.&amp;nbsp; Just to illustrate my point:&lt;/P&gt;&lt;P&gt;[codesnippet]MyParentBO.ForeignKeyField = MyInitialValue[/codesnippet]</description><pubDate>Wed, 17 Dec 2008 09:08:59 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Grandchild BO does not get foreign key value from Parent Insert</title><link>http://forum.strataframe.net/FindPost21244.aspx</link><description>Hi all -&lt;br&gt;
&lt;br&gt;
Does anyone know if the use of RegisterForeignKey() would be a solution to this problem?</description><pubDate>Wed, 17 Dec 2008 08:41:45 GMT</pubDate><dc:creator>Alex Luyando</dc:creator></item><item><title>RE: Grandchild BO does not get foreign key value from Parent Insert</title><link>http://forum.strataframe.net/FindPost21242.aspx</link><description>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.&lt;br&gt;
&lt;br&gt;</description><pubDate>Tue, 16 Dec 2008 17:53:51 GMT</pubDate><dc:creator>Charles R Hankey</dc:creator></item></channel></rss>