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
kminevkminev 

Add values to a pick list via apex code.

Is there a way I can add my pick list values from an apex code. Samething for controlling pick list fields?

 

Thank you.

Ajay111Ajay111
YOU CAN USE THIS CODE IN CONTROLLER FOR vf PAGE   

public List<SelectOption> getListType() { List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption('','--None--')); Schema.DescribeFieldResult fieldResult = account.Type.getDescribe(); List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues(); for( Schema.PicklistEntry f : ple) { options.add(new SelectOption(f.getLabel(), f.getValue())); } return options; }

 

StephenYS10000StephenYS10000
Once I have build a visualforce page for the component. How do I collect and save the value from the picklist to the underlying object record?