Toggle Side Panel

  • Blogs
  • 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
  • Contact Us
  • Discussions
More options
    Sign in Sign up
    • Blogs
    • 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
    • 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 7 years 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

    Popular Salesforce Blogs

    Salesforce Financial Services

    How Salesforce Financial Services Cloud Solves Problems For FinTech Companies

    Blog in Others

    Working in the financial services industry is not an easy-breezy thing to do. It is all about managing people’s wealth and helping them plan their lives, literally.…

    Financial Management Cloud, financial services, Salesforce Apps, Salesforce Consulting Company, Salesforce Consulting Services
    Nauman Aug 16, 2019
    4,348  Views
    salesforce devops

    Where is Salesforce DevOps Heading? Is it the Future, and if so How?

    Blog in Salesforce

    Salesforce DevOps is distinct. It enables efficiency and collaboration among shareholders that some other platforms just cannot provide. It’s not as if DevOps is extremely different from…

    Automated Deployments, B2B IT Firm, CI Technologies, CI Tools, Code Development
    Algoworks Jul 12, 2022
    2,558  Views
    Collections in Salesforce

    Collections in Salesforce - A Brief Guide

    Blog in Salesforce

    Collections could be a sort of variable that can store numerous records. For case, List can store numerous Account object's records. Let us presently have…

    Apex Types, Cluster Documentation, Collection Sorts, Collections, Collections in Salesforce
    Marziya Apr 27, 2021
    3,359  Views

    Popular Salesforce Videos

    Salesforce Admin Introduction - Salesforce Admin Tutorial

    Salesforce Admin Introduction - Salesforce Admin Tutorial

    Video in Salesforce Admin

    Salesforce Administrators work with stakeholders to define system requirements and customize the platform. To put it simply, they enable users to get the most out of…

    Salesforce Training, Salesforce Tutorial, Salesforce Admin, Salesforce Video, Salesforce Administrators
    Jogender Dec 27, 2021
    2,705  Views
    Connect Marketing Cloud with Salesforce CRM | PART 1

    Connect Marketing Cloud with Salesforce CRM | PART 1

    Video in Salesforce Stories, Marketing

    Salesforce Marketing Cloud is a customer relationship management (CRM) platform for marketers that allows them to create and manage marketing relationships and campaigns with customers.…

    salesforce, CRM, Salesforce Marketing Cloud, Salesforce Video, Customers
    Prafull Jun 15, 2020
    2,262  Views
    Salesforce Billing and Cryptocurrency

    Salesforce Billing and Cryptocurrency

    Video in Others, Salesforce Stories

    THE GOAL: In this video, you're going to learn how Cryptocurrencies can work with Salesforce Billing. ☝️ BEFORE YOU BEGIN, KNOW THIS: 1. In terms…

    salesforce, Salesforce Video, Business, Salesforce Billing, Cryptocurrency
    Jogender Jul 6, 2020
    1,640  Views

    Popular Salesforce Infographics

    CPQ software infographic

    7 Key Factors to Keep in Mind When Selecting Salesforce CPQ Software

    Infographic in Salesforce CRM

    Today, sales teams are increasingly overwhelmed with complex product offerings and customers’ expectations to deliver quick and personalized experiences. That’s why, sales professionals are inclining…

    Salesforce, CRM, Salesforce Infographic, Customer Experience, Sales Teams
    Rohit Thakur Apr 7, 2022
    2,510  Views

    Streamlining the Sales Process with Salesforce CPQ

    Infographic in Salesforce Products

    Implementing Salesforce CPQ offers numerous business advantages, such as automating tasks, including sales quotations and price determination. Businesses that use Salesforce CPQ can expect increased…

    Salesforce, Salesforce CPQ
    Fexle Services Jul 8, 2024
    890  Views

    CRM Solutions for Travel Agencies: Enhancing Customer Experience and Operational Efficiency

    Infographic in Salesforce CRM

    CRM Solutions for Travel Agencies: Enhancing Customer Experience and Operational Efficiency In the ever-evolving world of travel, customer expectations are higher than ever. With the…

    James Nov 25, 2025
    184  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®.

    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.