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 6 years, 12 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

    Defining Salesforce Marketing Cloud Engagement and Why It's Crucial For Businesses

    Blog in Salesforce Cloud Platform

    Salesforce Marketing Cloud Engagement previously known as Marketing Cloud Email Studio can play a critical part in a company's marketing strategy, helping develop client connections…

    Brand Awareness, Business, Business Needs, Business Requirements, Campaign
    Apphienz Jun 20, 2022
    2,045  Views

    How To Raise Your Profile Within The Salesforce Ecosystem

    Blog in Salesforce Career

    Raising your profile is not about showing off. It’s more about building your confidence, and letting people know that you are the GoTo perosn so…

    career, DF19, Dreamforce 2019, Networking, Salesforce Career
    Heather Dec 13, 2019
    4,475  Views
    What is a Queue in Salesforce?

    What is a Queue in Salesforce? | All You Need to Know

    Blog in Salesforce

    Salesforce queues facilitate the prioritization, dissemination, and assignment of data to teams that collaborate within an organization. Because of queues, employee tasks are more effectively…

    Assignment Rules, Best Salesforce Tutorials, Custom Objects, Data Structures, Lead Owner
    NAVDITA DAHIYA Jan 12, 2023
    2,858  Views

    Popular Salesforce Videos

    How to Log an Admin Assist Support Case in Help and Training in Salesforce Help

    How to Log an Admin Assist Support Case in Help and Training in Salesforce Help

    Video in Salesforce Stories, Salesforce Training

    Do you need to log a case with Admin Assist Salesforce Support but aren't sure how to go about it? Do you need help filling…

    Salesforce Training, salesforce, Salesforce Video, Salesforce Learning, Log a Salesforce Support Case
    Neha Yadav Aug 27, 2020
    2,794  Views
    Salesforce Apex Tutorial for beginners | Apex Salesforce Tutorial

    Salesforce Apex Tutorial for beginners | Apex Salesforce Tutorial

    Video in Salesforce Apex

    Apex is a proprietary language developed by Salesforce.com. It is a strongly typed, object-oriented programming language that allows developers to execute flow and transaction control statements on the…

    Salesforce Training, Salesforce Tutorial, Salesforce Apex, salesforce, Apex
    Prafull Jun 6, 2022
    2,557  Views
    Security in Salesforce | Security Levels in Salesforce

    Security in Salesforce | Security Levels in Salesforce

    Video in Salesforce Security

    This 'Security in Salesforce'  video by Edureka will help you understand the different levels of security in Salesforce. It will also talk about some of…

    Salesforce Tutorial, Salesforce Security, Salesforce Video, Salesforce Learning, Best Practices
    Jogender Sep 30, 2021
    2,531  Views

    Popular Salesforce Infographics

    Salesforce Developer Career Path

    Infographic in Salesforce Certifications

    Embarking along your journey of becoming a Salesforce Technical Extraordinaire is a wise move, as programming in Apex and Visualforce is one of the hottest,…

    Salesforce Consultant, Salesforce Developers, Salesforce Administrator, Certified Salesforce Admin, Salesforce Certifications
    Portia Mar 21, 2018
    7,435  Views

    7 Must Know Features on the New Salesforce AppExchange

    Infographic in AppExchange

    Personalized recommendations, intelligent search, and new solutions are just a few of the exciting new features on the brand new AppExchange. Check it out at…

    Salesforce Apps, Salesforce App Development, Salesforce App Cloud, Salesforce Apps for Business, Salesforce Appexchange
    Portia Jan 17, 2018
    829  Views

    Overview of Salesforce AppExchange Apps Market: Key Insights and Trends for 2024

    Infographic in AppExchange

    The Salesforce AppExchange marketplace continues to expand, offering a diverse array of applications designed to enhance various business operations. Our 2024 analysis delves into the…

    Salesforce Appexchange, Salesforce Research, Salesforce Market Research, Salesforce AppExchange Platform, AppExchange Application
    SFApps.info Jul 5, 2024
    1,313  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.