+ Start a Discussion
SFDev@321SFDev@321 

How to get the Picklist field values in to look-up feild.

I have a custom obejct Sales_c in this i have 2 feilds:- 


1> competitor1_c :- Picklist
2> competitor2_c :- Picklist

 

Now, i have created another 2 look-up feilds :-

 

3> Comp1_c : Lookup feild
4> Comp2_c : Lookup feild


Now, i want to capture all picklist feilds(competitor1_c, competitor2_c) values in to look-up feilds (Comp1_c, Comp2_c).

 

 

Also,i want to have those values which already exists in picklist values to lookups in existing records as well.....

bvramkumarbvramkumar

It looks like a synchronization task. If you are looking to process millions of such records you should probably consider first the schedule batch apex process.

 

And in your batch apex.

1) Collect all the competitor1_c and competitor2_c in to two different sets setComp1 and setComp2.

2) Query the Master Competitor object by applying a filter on name based on setComp1 and setComp2.

3) Create two maps for Competitor1 and Competitor2. each with key as name and Id as value based on the Query result in Step2

4) Now use the map created in Step3 and fill in the respective Competitor Ids in your target object records and update all those target records.