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

    Learn Salesforce Einstein – Chapter 2 (AI Buddy Installation)

    Learn Salesforce Einstein – Chapter 2 (AI Buddy Installation)

    Blog in AI and ML, Salesforce Einstein

    AI Buddy Installation 1. Login in the org, where you want to install the App. 2. Go to Download Page and click on the latest…

    Learn Einstein, Salesforce Einstein, Salesforce Einstein Language
    0to1Code.Com Sep 13, 2017
    4,804  Views

    How to Reach Better User Experience of a Salesforce App with a Webix-based Data Grid

    Blog in Others

    Each growing business should continuously evolve since customers are becoming more demanding every day. As a result, software solutions are becoming obsolete very fast. The…

    App Cloud, Customer Relationship Management, IOT, Javascript in Salesforce, Marketing Cloud
    Aleksandra Feb 21, 2019
    4,866  Views

    Salesforce Summer ’18 Release - Key Points

    Blog in Salesforce Releases

    Three times per year, Salesforce release a new version of their products, full of new and exciting features. The first and second weekend of June…

    Salesforce Consultant, Salesforce Consulting, Salesforce Development, Salesforce Partner, salesforce summer release
    KeyNode Jun 18, 2018
    5,006  Views

    Popular Salesforce Videos

    How to Send a Slack Message from Salesforce Marketing Cloud

    How to Send a Slack Message from Salesforce Marketing Cloud

    Video in Salesforce Training

    In this video, Cameron Robert shows how to use the Slack Message API to send a message from Salesforce Marketing Cloud to a Slack Channel.…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Marketing Cloud, Salesforce Video
    Cameron Jul 25, 2022
    2,407  Views
    The Only Salesforce Developer Video Tutorial Course You Will Ever Need!

    The Only Salesforce Developer Video Tutorial Course You Will Ever Need!

    Video in Salesforce Training, Salesforce Development

    A Salesforce developer is a programmer who builds Salesforce applications across various PaaS (Platform as a Service) platforms. A Salesforce developer has an understanding of…

    Salesforce Training, Salesforce Tutorial, Salesforce Development, Salesforce Developer, salesforce
    Prafull Jan 28, 2022
    2,521  Views
    Handle Events in Lightning Web Components | Salesforce Tutorial

    Handle Events in Lightning Web Components | Salesforce Tutorial

    Video in Lightning, Salesforce Training

    Watch this video and learn about the following: Create an app that includes multiple components. Describe the file structure of a complex component. Handle events.

    Salesforce Training, Salesforce Tutorial, Salesforce Video, Lightning Web Components, Salesforce Learning
    Rupal Kakkar Jun 24, 2021
    2,258  Views

    Popular Salesforce Infographics

    7 Must Know Features on the New Salesforce AppExchange

    Infographic in AppExchange

    The AppExchange is an online marketplace for Salesforce apps, components, and consulting services. If you're a Lightning Platform developer or consultant, the AppExchange is the…

    Salesforce Customization, Salesforce Appexchange, Salesforce Infographic, App Category Pages, Lightning Bots
    Deepti Dec 14, 2018
    3,591  Views

    Management: Salesforce – 27 Incredible Sales Tips

    Infographic in Sales

    Get a complete view of your customers, including activity history, key contacts, customer communications, and internal account discussions.. With sales software from Salesforce (Salesforce Sales…

    Sales Reps, Sales, Salesforce Data Management, Business Success, Marketing Automation
    Hazel Apr 2, 2018
    3,479  Views
    Salesforce Buzz

    Salesforce Buzz | An Infographic

    Infographic in Salesforce Stories

    While Salesforce has been coined as the World's #1 CRM, there has been a constant buzz around the stats and facts of it. Almost 58%…

    Salesforce Cloud Platform, Salesforce Analytics, Salesforce, Salesforce Buzz, CRM
    CEPTES Jan 9, 2018
    3,398  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.