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

    Popular Salesforce Blogs

    What are field dependency?

    What are Field Dependencies in Salesforce in 2023? | All You Need to Know

    Blog in Others

    Salesforce is a powerful CRM platform that allows businesses to customize and tailor the software to their specific needs. One of the ways this is…

    automation tools, Best Practices, Complexity, Consistency, Controlling Field
    Mohit Kumar Apr 20, 2023
    2,770  Views

    Understanding sObjects in Salesforce: A Comprehensive Guide

    Blog in Salesforce

    Introduction  In the realm of Salesforce, sObjects play a crucial role in managing and manipulating data. Short for "Salesforce Objects," sObjects are the fundamental data…

    APIs, Automation, Business Requirements, Consistency, Contacts
    vishnu kumar Jul 4, 2023
    2,596  Views
    Steps to Install the Force.com IDE Plug-In in Eclipse

    Steps to Install the Salesforce Force.com IDE Plug-In in Eclipse

    Blog in Salesforce integration

    Force.com IDE can be installed into your existing Eclipse distribution. Following are the prerequisite to install Force.com IDE on your workstation : Don’t forget to check…

    Eclipse IDE, Force.com Debugger, Force.com IDE, Force.com Lightning Support., Force.com Plugin
    Ratnakar Mar 13, 2018
    45,294  Views

    Popular Salesforce Videos

    Salesforce Billing - Digital Wallets and Alternative Payment Methods

    Salesforce Billing - Digital Wallets and Alternative Payment Methods

    Video in Others, Salesforce Stories

    THE GOAL:  In this video, you will learn how to use Alternative Payment Methods and Digital Wallets with Salesforce Billing. BEFORE YOU BEGIN, KNOW THE…

    salesforce, Salesforce Video, Salesforce Billing, Digital Wallets, Alternative Payment Methods
    Jogender Jul 1, 2020
    3,746  Views
    Use Case Hierarchy to Link Cases in Salesforce

    Use Case Hierarchy to Link Cases in Salesforce

    Video in Salesforce Stories

    Want to link your cases, so you and your team have a complete view of what’s going on with a customer? Do you want to…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Video, Service Cloud
    Abhishek Mar 7, 2022
    3,054  Views
    Future of Salesforce Job Market | The Shrey Sharma Show

    Future of Salesforce Job Market | The Shrey Sharma Show

    Video in Salesforce Stories

    This is the very first episode of The Shrey Sharma Show with Christopher A Hopper. They discussed Salesforce. Below is a list of questions they…

    Salesforce Developer, Salesforce Consultant, salesforce, Salesforce Ecosystem, Salesforce Industry
    Nauman Sep 27, 2021
    1,660  Views

    Popular Salesforce Infographics

    Unlock Agile and Efficient Salesforce Testing With AI-Driven Tools

    Infographic in AI and ML, Salesforce Cloud Platform, Salesforce Stories

    Like every industry, the world of software testing and quality assurance has also gone under massive development with the emergence of AI technology. Developers and…

    Salesforce Training, Salesforce Testing, AI In Salesforce, Salesforce Infographic, Infographic
    Sukhwinder Singh Oct 11, 2023
    1,202  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
    3,184  Views
    Marketing Cloud Products

    Different Salesforce Marketing Cloud Products

    Infographic in Salesforce Marketing Cloud

    Salesforce Marketing Cloud offers a number of products and solutions for customer journey management, advertising, social, email, mobile, content creation, web personalization, and data analysis.…

    Salesforce Development, Marketing, Salesforce, CRM, Cloud
    Cyntexa May 6, 2021
    5,490  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.