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, 7 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

    A Case Study of Salesforce Health Cloud and Salesforce Service Cloud Implementation

    Blog in Salesforce

    In the rapidly evolving healthcare landscape, technology plays a pivotal role in enhancing patient care and operational efficiency. This case study explores how a physician-run…

    Salesforce Health Cloud, Salesforce Service Cloud, Salesforce Service Cloud Implementation, Salesforce Service Cloud Integration Services, Salesforce Service Cloud Solutions
    Dean Sep 22, 2025
    1,045  Views

    Hire Salesforce Sales Cloud Developer

    Blog in Salesforce

    Sales teams don’t fail because they lack effort. They fail because their tools don’t support the way they actually sell. Spreadsheets get messy, leads slip…

    hire Salesforce Sales Cloud developers, Salesforce, Salesforce Development, Salesforce Development Services
    Dean Feb 27, 2026
    235  Views

    Salesforce Stripe Payment Processing

    Blog in Salesforce integration

    In today’s fast-paced digital world, businesses of all sizes constantly seek ways to provide a seamless customer experience. One crucial aspect of this experience is…

    APIs, Commerce Cloud, Coupons, Credit Cards, CRM
    Kizzy Consulting Jul 31, 2023
    1,870  Views

    Popular Salesforce Videos

    How to install Salesforce for Outlook in 2019

    How to install Salesforce for Outlook in 2019

    Video in Salesforce Integration

    Watch this video to learn how to install Salesforce for Outlook. ? Also, we cover all the details in our blog post at https://ascendix.com/blog/integrating-salesforce-outlook/

    Salesforce Products, Easy Way To Learn Salesforce, Best Salesforce Tutorials, Salesforce for Outlook, Outlook integration
    Valeria Feb 28, 2019
    1,879  Views
    Maximizing Salesforce Lightning Experience and Lightning Component Performance

    Maximizing Salesforce Lightning Experience and Lightning Component Performance

    Video in Lightning

    00:04:57 - Agenda 00:06:08 - Difference between Salesforce Classic and Salesforce Lightning 00:17:45 - Demo: Load time comparison between Salesforce Classic and Salesforce Lightning when…

    Salesforce Lightning, Salesforce Lightning Experience, salesforce, UI, Trailhead
    Neha Yadav Apr 23, 2020
    1,415  Views
    Smart Merchandising with Salesforce Einstein AI

    Smart Merchandising with Salesforce Einstein AI

    Video in AI and ML, Salesforce Einstein

    Smart Merchandising is a holistic tool that magically combines rich insights from site-wide search, navigation, purchases, and the customer’s current session with strategic business goals.…

    Salesforce Training, Salesforce Video, Customers, Salesforce Learning, Business
    Algoworks Jun 30, 2021
    1,663  Views

    Popular Salesforce Infographics

    Boost Sales and Marketing with Salesforce Einstein 1

    Infographic in Salesforce Apex, Salesforce Products

    Salesforce Einstein 1 is a suite of artificial intelligence (AI) tools designed to enhance business efficiency and decision-making. Around 80% of customers expect companies to…

    AI and Einstein, Salesforce, Einstein
    Fexle Services Jul 10, 2024
    1,020  Views

    Why Integrate Your Pardot Account with Salesforce?

    Infographic in Salesforce integration

    Salesforce Sales Cloud is primarily a sales tool while Pardot is a marketing automation platform. Both are designed to increase sales and maximize efficiency for…

    Salesforce Sales Cloud, Salesforce Pardot, Salesforce Integration, Salesforce Records Management, Marketing Automation
    Rupal Kakkar Jul 30, 2018
    2,997  Views
    customer relation

    6 Signs Your Business Needs a Salesforce CRM

    Infographic in Salesforce CRM

    When people talk about Customer Relationship Management (CRM), they are usually referring to a system that helps with contact management, sales management, productivity, and more.…

    CRM, Customer Relationship Management, Salesforce CRM, Contact Management, Customer Journey
    Nauman Dec 22, 2021
    3,376  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.