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

    Salesforce Public Cloud for Education

    Blog in Salesforce

    Digitalization has transformed the way we live and has made data effortlessly accessible in a world that is always on the go, and it has…

    Business Technology, Cloud Computing, CRM, Customer Stories, Customer Success
    TechForce Jun 20, 2024
    1,281  Views

    The significance of Salesforce and Facebook Integration

    Blog in Salesforce integration

    Facebook is a leading social networking app in today’s market scenario for doing tasks like share updates, photos or videos with friends and community. Salesforce…

    Facebook, Salesforce and Facebook Integration, Salesforce App, Salesforce Einstein, Salesforce Integration
    AwsQuality Jan 23, 2020
    3,755  Views

    10 best Reports in a Salesforce Marketing Dashboard

    Blog in Salesforce Implementation

    Salesforce.com provides a variety of CRM dashboards for businesses to grow. From Sales & marketing dashboards to customer service dashboards, these platforms mainly help in…

    Lead Source, Marketing Campaigns, Salesforce Custom Fields, Salesforce Leads, Salesforce Marketing Cloud
    Edifyself Aug 22, 2017
    43,860  Views

    Popular Salesforce Videos

    Introduction to Salesforce Apex for Developers

    Introduction to Salesforce Apex for Developers

    Video in Salesforce Apex, Salesforce Training

    Have you ever wanted to write a Trigger in Salesforce? This workshop is designed for people who would like to begin learning the basics of…

    Apex Data Loader, Salesforce Apex Class, Salesforce Apex Tutorial, Salesforce Apex Tutorial For Beginners, Salesforce Apex Programming
    Abhay Feb 15, 2018
    1,978  Views
    Marketing Cloud Connect: View Full Resolution Emails in Sales or Service Cloud

    Marketing Cloud Connect: View Full Resolution Emails in Sales or Service Cloud

    Video in Salesforce Implementation

    Thumbnails don't always cut it. Sometimes you need the full resolution Marketing Cloud email in Sales or Service Cloud to see what was sent to…

    Salesforce Training, Salesforce Tutorial, Salesforce Visualforce, Salesforce Rest API, Apex
    DB Mar 3, 2021
    2,386  Views
    Custom Portfolio in Salesforce | Mini Project | Salesforce Tutorials

    Custom Portfolio in Salesforce | Mini Project | Salesforce Tutorials

    Video in Others, Salesforce Training

    In this video, we will create a custom portfolio in Salesforce. We will create a custom community in Salesforce and customize it to create the…

    Salesforce Training, salesforce, Salesforce Video, Salesforce Learning, Portfolio
    Kapil Oct 8, 2020
    4,076  Views

    Popular Salesforce Infographics

    process chart

    Explore The Salesforce Support Services Process Chart

    Infographic in Others, Salesforce Stories

    This infographic helps you to explore the Salesforce Services process chart. Go through it and let me know in the comments in case of any…

    Salesforce, Salesforce Infographic, Salesforce Support Services, Process Chart, Service Cloud
    Prafull Jun 22, 2020
    2,748  Views
    Salesforce Lightning

    Enhance Productivity with Salesforce Lightning

    Infographic in Lightning

    As a business professional, you are always looking for ways to increase productivity while keeping your team motivated and moving forward. Salesforce Lightning platform is…

    Salesforce, Salesforce Infographic, Infographic, Salesforce Lightning, Salesforce Learning
    Rupal Kakkar Jan 5, 2022
    2,631  Views

    What is CRM Process?

    Infographic in Salesforce CRM

    CRM denotes Customer Relationship Management (CRM). The name itself says that it is a system for managing the relationship with customers. It includes effective software…

    Salesforce Analytics, CRM, Customer Relationship Management, Customer Success, Salesforce CRM
    swetha Dec 3, 2018
    2,866  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.