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
SF-devSF-dev 

How to populate Dependent PickList value in Apex Class/ Trigger

I need to populate some picklist value on an Opportunity Trigger. 

 

There are two pickList : 'PickList 1' and 'PickList2' . 2nd one  is dependent on the earlier.When I populate PickList1 on the trigger, how can I get the relevent value of 'PickList2' ?

 

Any help will be appreciated . Thanks in Advance!

dmchengdmcheng

You have to use IF statements on PickList1 and hardcode the Picklist2 values in your code.  If there is a one-to-one correspondence between Picklist1 and Picklist2, you could instead set up a lookup table using Custom Settings and create a Map from that.