Displaying default picklist value on Visualforce page using apex class controller
Here, we do not need to use SOQL and thus eliminates the Salesforce Governer limitations.

Check the default checkbox against the value which needs to be defaulted
Steps to make the default value in Lead Object field called Status
Setup -> Lead (Object) -> Click Status field -> check the default checkbox against the value from Status value lists.

I have chosen – “Open – Not Contacted”.

Apex Class:

public class defaultPicklistController {

public Lead lead {
public List < SelectOption > statusOptions {
// Constructor called on load.
public picklistController() {
lead = new Lead();
statusOptions = new List < SelectOption > ();

// Use DescribeFieldResult object.
Schema.DescribeFieldResult statusFieldDescription = Schema.Lead.Status.getDescribe();
// For each picklist value, a new select option created
for (Schema.Picklistentry picklistEntry: statusFieldDescription.getPicklistValues()) {
statusOptions.add(new SelectOption(pickListEntry.getValue(), pickListEntry.getLabel()));
// check default value and assign
if (picklistEntry.isDefaultValue()) {
lead.Status = picklistEntry.getValue();

Visualforce Page:

<apex:page controller="defaultPicklistController">
<apex:form >
<b>Default value of Lead Status : </b>
<apex:selectList size="1" value="{!lead.Status}">
<apex:selectOptions value="{!statusOptions}"/>



Written by 

I am Sakthivel Madesh, a certified Salesforce Advanced Developer & Administrator working on Salesforce Technology since 2011. I am currently working in Techforce Services as Sr. Salesforce Developer. I have worked on multiple technologies Like PHP, Java, Salesforce, I am very passionate about Salesforce and to earn 15x Salesforce Certification. I love Trailhead for learning Salesforce Skill and Become a Trailhead 5x Ranger too. I Love to Learn & Share my Salesforce knowledge to Salesforce Learners/Beginner using My Blog and Salesforce Community.

Leave a Reply

Your email address will not be published. Required fields are marked *