You need to sign in to do that
Don't have an account?
Dea73
Many to many relation ship junction object question----need help!!!
Hi,
I have an Object A that has a many to many relationship to Object B.
Because of this i have created junction Object C
I have created a wizard that makes it possible to select 3 object B.
In my controller extension I'm able to create a new instance of Object A along with the 3 selected instances of Object B correctly populated ( as lookup fields)
How do i retrieve the ids of the lookup fields to create 3 seperate instances of the junction object????
Find below a sample code :
// Create a record in Object A -- RecA
ObjectA__c objA = New ObjectA__c(Name='VKS__A');
for(Integer i=0; i<3 ; i++)
{
ObjectB__c objB = New ObjectB__c(Name='VKS__B',ObjectA_Lookup__c =:RecA.id);
insert objB;
ObjectC__c objC = New ObjectC__c(Name='VKS__C',ObjectA_Lookup__c =:RecA.id, ObjectB_Lookup__c =:objB.id);
inset objC;
}