• WHO WE ARE
  • WHAT WE DO
    • Salesforce
      • Implementations
        • Sales Cloud
        • Service Cloud
        • CPQ
        • Field Service Lightning
        • Field Service for SMEs
      • Developments
        • Salesforce Customization
        • Custom Application Development
        • AppExchange Product Development
      • Migrations
        • Classic to Lightning Migration
        • Other Systems to Salesforce Migration
      • Integrations
    • Data Science
      • BI Solutions
      • AI/ML solutions
      • Agentic AI
  • HOW WE DO
    • Delivery Model
    • Our Works
  • REACH US
    • Contact Us
    • Careers
  • BLOG
    • WHO WE ARE
    • WHAT WE DO
      • Salesforce
        • Implementations
          • Sales Cloud
          • Service Cloud
          • CPQ
          • Field Service Lightning
          • Field Service for SMEs
        • Developments
          • Salesforce Customization
          • Custom Application Development
          • AppExchange Product Development
        • Migrations
          • Classic to Lightning Migration
          • Other Systems to Salesforce Migration
        • Integrations
      • Data Science
        • BI Solutions
        • AI/ML solutions
        • Agentic AI
    • HOW WE DO
      • Delivery Model
      • Our Works
    • REACH US
      • Contact Us
      • Careers
    • BLOG
  • [email protected]
  • (+91) 44-49521562
Merfantz - Salesforce Solutions for SMEs
Merfantz - Salesforce Solutions for SMEs
  • WHO WE ARE
  • WHAT WE DO
    • Salesforce
      • Implementations
        • Sales Cloud
        • Service Cloud
        • CPQ
        • Field Service Lightning
        • Field Service for SMEs
      • Developments
        • Salesforce Customization
        • Custom Application Development
        • AppExchange Product Development
      • Migrations
        • Classic to Lightning Migration
        • Other Systems to Salesforce Migration
      • Integrations
    • Data Science
      • BI Solutions
      • AI/ML solutions
      • Agentic AI
  • HOW WE DO
    • Delivery Model
    • Our Works
  • REACH US
    • Contact Us
    • Careers
  • BLOG

How to Set Default Picklist Value by using VisualForce Page with Apex Class

  • July 27, 2017
  • Merfantz Editor
  • Salesforce Developments Tutorial
  • 0

The below code explains, create picklist values and set a default value in the visual force page with apex class.

Step 1: Create visualforce page with the following code.

<apex:page controller=”SettingDefaultPicklist”>
<apex:form >
<apex:selectList value=”{!str}” size=”1″ multiselect=”false”>
<apex:selectOptions value=”{!TimingList}“>
</apex:selectOptions>
</apex:selectList>
</apex:form>
</apex:page>

Step 2: Create apex class with the below code.

public class SettingDefaultPicklist {
//Initialization
public string str {get; set;}
public List<SelectOption> TimingList=new List<SelectOption>();
//Constructor
public SettingDefaultPicklist() {
str = ‘09.30 am to 12.30pm’;
}
//SelectOption method
public List<SelectOption> getTimingList () {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption(‘01.30 am to 06.30pm’,’01.30 am to 06.30pm’));
options.add(new SelectOption(‘12.30 am to 1.30pm’,’12.30 am to 1.30pm’));
options.add(new SelectOption(‘09.30 am to 12.30pm’,’09.30 am to 12.30pm’));
return options;
}
}

Result:-

We are the ISV Partners and Please reach us for custom development => www.merfantz.com

———————————– *****Thank You*****—————————————-

Author Bio

Merfantz Editor
+ Recent Posts
  • August 4, 2023
    How to Setup CRM Analytics for Financial Services Cloud
  • August 2, 2023
    How to Get Started with Salesforce Hyperforce - Merfantz
  • July 28, 2023
    Health Cloud Mastery: Salesforce Trailhead for Effective Healthcare CRM
  • July 26, 2023
    How to integrate Data cloud and Marketing cloud In Salesforce
Tags: Field Service ManagementFieldax
  • Previous How to Get pdf File from My Personal Documents using Visualforce Page
  • Next How to Open pdf File From Static Resource using Visualforce Page

Leave a Reply

You must be logged in to post a comment.

Merfantz Technologies is a leading Salesforce consulting firm dedicated to helping small and medium enterprises transform their operations and achieve their goals through the use of the Salesforce platform. Contact us today to learn more about our services and how we can help your business thrive.

Discover More

Terms and Conditions
Privacy Policy
Cancellation & Refund Policy

Contact Info

  • No 96, 2nd Floor, Greeta Tech Park, VSI Industrial Estate, Perungudi, Chennai 600 096, Tamil Nadu, INDIA
  • (+91) 44-49521562
  • [email protected]
  • 9:30 IST - 18:30 IST

Latest Posts

Mastering Attachment Compression for Salesforce Developers May 9, 2025
Salesforce API Integrations: Connect with Slack, Zoom, and Teams May 2, 2025
Guide to Streamlining Sales Success
Mastering Salesforce CPQ: A Comprehensive Guide to Streamlining Sales Success April 17, 2025

Copyright @2023 Merfantz Technologies, All rights reserved