Toggle Side Panel

  • Home
  • Articles
    • All Articles
    • Blogs
    • Videos
    • Infographics
  • Consultants
    • Salesforce Product Expertise
      • Top Salesforce ConsultantsTop Salesforce Consultants
      • Marketing Cloud ConsultantsMarketing Cloud Consultants
      • Service Cloud ConsultantsService Cloud Consultants
      • Experience Cloud ConsultantsExperience Cloud Consultants
      • Analytics Cloud ConsultantsAnalytics Cloud Consultants
    • Salesforce Industry Expertise
      • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
      • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
      • Health Cloud ConsultantsHealth Cloud Consultants
      • Commerce Cloud ConsultantsCommerce Cloud Consultants
      • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
    • Salesforce Experts by Location
      • USATop Salesforce Consultants in USA
      • IndiaTop Salesforce Consultants in India
      • AustraliaTop Salesforce Consultants in Australia
      • United KingdomTop Salesforce Consultants in UK
      • CanadaTop Salesforce Consultants in Canada
  • Webinars
  • Marketplace
  • Advertise With Us
  • Contact Us
  • Discussions
More options
    Sign in Sign up
    • Home
    • Articles
      • All Articles
      • Blogs
      • Videos
      • Infographics
    • Consultants
      • Salesforce Product Expertise
        • Top Salesforce ConsultantsTop Salesforce Consultants
        • Marketing Cloud ConsultantsMarketing Cloud Consultants
        • Service Cloud ConsultantsService Cloud Consultants
        • Experience Cloud ConsultantsExperience Cloud Consultants
        • Analytics Cloud ConsultantsAnalytics Cloud Consultants
      • Salesforce Industry Expertise
        • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
        • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
        • Health Cloud ConsultantsHealth Cloud Consultants
        • Commerce Cloud ConsultantsCommerce Cloud Consultants
        • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
      • Salesforce Experts by Location
        • USATop Salesforce Consultants in USA
        • IndiaTop Salesforce Consultants in India
        • AustraliaTop Salesforce Consultants in Australia
        • United KingdomTop Salesforce Consultants in UK
        • CanadaTop Salesforce Consultants in Canada
    • Webinars
    • Marketplace
    • Advertise With Us
    • Contact Us
    • Discussions
    Close search

    Activity › Forums › Salesforce® Discussions › How to display picklist values based on Lookup value on VF page in Salesforce?

    Tagged: Account Lookup, Apex, LookUp Value, Picklist Values, Salesforce Visualforce Page

    • Salesforce® Discussions

      How to display picklist values based on Lookup value on VF page in Salesforce?

      Posted by Laveena on August 27, 2019 at 5:41 AM

       

      I created a custom VF page to create custom object record. I have a Account lookup on page.

      So whenever a user selects value from the lookup I would like to show dynamic picklist options on VF page by querying with LookupID for example I want to show names on dropdown, queried from selected lookup Id before saving the record.

      Class:

      public class createPriceRecord
      {
      public Price__c price{get; set;}
      public Price__c priValue;
      public Id lookupId{get;set;}
      public Price__c ReqOpp;

      public createPriceRecord (ApexPages.StandardController controller) {
      price= (Price__c)controller.getRecord();
      stdCtrl=controller;
      }
      private ApexPages.StandardController stdCtrl;

      public void AccPopulated()
      {
      priValue= (Price__c)stdCtrl.getRecord();
      }

      public List<selectOption> getselectValues()
      {
      List<Prod__c> relatedprod = new List<Prod__c>();

      relatedprod = [Select Id,name from Prod__c where AccLookup__c.id =: priValue.Account__r.ID ]; // trying to get Account id from VF page

      List<SelectOption> Options = new List<SelectOption>();

      Options.add(new SelectOption('','-None-'));

      for(Prod__c prod:relatedprod)
      {
      Options.add(new SelectOption(prod.Id,prod.Name));
      }
      return Options;
      }

      public PageReference SaveRec(){

      price.Look_Up__c = lookupId;
      insert price;

      PageReference p=new PageReference('my.salesforce.com/'+price.Id);
      return p;

      }

      }

      Page:

      <apex:page standardController="Price__c" extensions="createPriceRecord" tabStyle="Price__c">
      <apex:form >
      <apex:pageBlock title="Price Edit" mode="edit">
      <apex:pageBlockButtons>
      <apex:commandButton value="Save" action="{!SaveRec}"/>
      </apex:pageBlockButtons>

      <apex:pageBlockSection columns="2" title="Price Information">
      <apex:inputField value="{!price.AccountId}">
      <apex:actionSupport event="onchange" action="{!AccPopulated}" immediate="true" />
      </apex:inputfield>

      <apex:selectList value="{!lookupId}" title="Select" multiselect="false" size="1" >
      <apex:selectOptions value="{!selectValues}"/>
      </apex:selectList>

      <apex:inputField value="{!price.name}"/>
      </apex:PageBlockSection>
      </apex:pageBlock>
      </apex:form >
      </apex:page>

      Laveena replied 6 years, 5 months ago 1 Member · 0 Replies
      • Account Lookup
      • Apex
      • LookUp Value
      • Picklist Values
      • Salesforce Visualforce Page
    • 0 Replies

    Log In to reply.

    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me

    application solution

    Popular Salesforce Blogs

    How to Write a Batch Apex in Salesforce

    Blog in Coding and Scripting

    In this post, let us learn about the Batch Apex and its usage. Once after completing this post, you will be able to write a…

    Batch, Batch Apex, Development, Salesforce Apex
    Sakthi Saranya Nov 10, 2019
    6,239  Views
    Fastest “For Loop” in Salesforce

    Fastest "For Loop" in Salesforce

    Blog in Coding and Scripting, Salesforce Implementation

    Loops play a very important part in our Lives. Whenever we need to play over large sets of Data, we usually use For Loops. But…

    CPU Time, Dataset in Salesforce, For Loop Execution, For Loop in Salesforce, For Loop Speed
    Manpreet Jan 23, 2018
    7,668  Views

    Salesforce Data Migration: Best Practices and Tips

    Blog in Data Migration

    Migrating data to Salesforce is a crucial step for businesses transitioning from legacy systems or consolidating multiple data sources into one powerful CRM. Done right,…

    Accounts in Salesforce, Data Import Wizard, Data Migration, ETL, Leads in Salesforce
    Dean Aug 27, 2025
    657  Views

    Popular Salesforce Videos

    Salesforce Flow Best Practices: Salesforce Flow Design Patterns

    Salesforce Flow Best Practices: Salesforce Flow Design Patterns

    Video in Salesforce Apex

    Salesforce Flow Design Patterns from Fundamentals to Mastery. In this session, we will talk about the top 10 Salesforce Flow best practices. We will talk…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Flow, Salesforce Video
    Prafull Dec 7, 2021
    4,935  Views
    Salesforce Apex Tutorial: Data Types

    Salesforce Apex Tutorial: Data Types

    Video in Salesforce Apex, Salesforce Training

    In this lesson, we are covering Salesforce Apex Data Types and we are covering primitive data types.

    Salesforce Tutorial, Salesforce Beginner Tutorial, Apex, Salesforce Apex Tutorial, Salesforce Apex Tutorial For Beginners
    Shiv Kumar Sharma Jan 24, 2018
    2,584  Views
    Experience the Most Flexible, Easiest, and Securest Way to Integrate Salesforce and Jira

    Experience the Most Flexible, Easiest, and Securest Way to Integrate Salesforce and Jira

    Video in Salesforce Integration

    Integrate standard and custom Salesforce objects with Jira to strengthen cross-functional collaboration and deliver a top-notch customer experience. Fast-Track Your Journey to Attaining Customer Centricity…

    salesforce, Salesforce Video, Salesforce Learning, Customer Experience, jira
    Shubham Oct 14, 2020
    2,010  Views

    Popular Salesforce Infographics

    Leverage Nonprofit trends with Salesforce Nonprofit Cloud

    Infographic in Salesforce Cloud Platform

    Salesforce Nonprofit Cloud is a suite of tools designed to help nonprofits take advantage of the latest trends and technologies. With the Nonprofit Cloud, your…

    Salesforce, Salesforce Infographic, Salesforce Nonprofit Cloud, Powerful Insights, Streamlined Processes
    Emorphis May 4, 2023
    1,011  Views

    How to Handle Failed Salesforce AppExchange Security Review?

    Infographic in AppExchange

    Common reasons for a ‘FAILED’ Salesforce AppExchange Security Review The most common reasons for failing a Salesforce AppExchange security review can vary, but they often…

    Salesforce Appexchange, AppExchange, Salesforce AppExchange Development Services
    Concretio Jul 2, 2024
    792  Views

    How to Become a Salesforce Consultant?

    Infographic in Salesforce Consultant

    Begin your Salesforce Consultant journey with Trailhead to learn about the modules offered by Salesforce to its users - admin, business users and developers to…

    Salesforce Apps, Salesforce Development, Salesforce Consultant, CRM, Salesforce Developers
    Emily Oct 12, 2018
    4,067  Views
    Footer Forcetalks logo

    support@forcetalks.com

    • twitterx

    Quick Links

    Advertise with Us

    Salesforce® Articles

    Dreamforce 2023

    Top Salesforce® Bloggers 2023

    Top Salesforce Consultants

    Get Listed

    Company

    Contact Us

    About Us

    Privacy Policy

    Terms & Conditions

    InsightHub

    Salesforce Blogs

    Salesforce Videos

    Salesforce Groups

    Salesforce Jobs

    © 2026 - Forcetalks ● All Rights Reserved

    Salesforce® is a trademark of Salesforce® Inc. No claim is made to the exclusive right to use “Salesforce”. Any services offered within the Forcetalks website/app are not sponsored or endorsed by Salesforce®.

    Try AuditMyCRM - It is a Salesforce CRM Audit tool which comprehensively scans your Salesforce org and gives you the list of errors or warnings you need to take care of.
    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.