function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Galeeb SKGaleeb SK 

Assigning Records to Objects

Hi,
Sorry SRK,My complete Scenario is
i have one scenario like this ,i have 3 objects like A,B,C.C is the junction object of both A and B .i assign the two records of B to A (like mapping), AND also assign those  same two records to C(like mapping). Inthat case when iam assigning those same two records to C,I want to  display  an Error  like this ' inserting duplicate records' . How to achieve this with APEX CODE? Please Tell me?

Regards
Galeeb SK
 
SRKSRK
As you have mentioned "C is the junction object of both A and B" , so which menas we are using c to connect A and B and we do not have any lookup of A on B object and vice versa

Stateting that 

So now as per you above satements 

we have 2 record of B object say B1 abd B2, which you link to A (let assume you likt it with a record of object A named as A1)


which mean you creata 2 record in object C say C1 and C2 and 
C1 connect A1 B1
and C2 connect A1 B2

Now i belive you want a functionality that if someone try to create a duplicate mapping like by creating anew record in C object C3 and try to connect A1 B1 or A1 B2 it give the error i belive that what you want 

if thats the requirment you can achive by using workflows and also by sing trigger apex code
Please provide you inout on the same
Galeeb SKGaleeb SK
not that one.C has MD relation ship with A and B
SRKSRK
yes that i got it when you say its a junction object 

can you please explane it throw example

Say A have 2 record A1 and A2
B have 2 record B1 and B2 
and C also have 2 record C1 and C2

I know its hard to explane again and again i am trying my bast to understand it