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

    Salesforce Customer 360

    Salesforce Customer 360 Innovations - Path to success

    Blog in Salesforce Products

    Enterprises are looking for solutions to improve their business operational efficiencies while facing challenging marketing situations such as logistics disruption, inflation, and workforce shortage. So,…

    Applications, Artificial Intelligence, B2B Sales, Business Essentials, Business Operations
    Melonleaf Oct 17, 2022
    2,558  Views

    How Integrating Salesforce with Accounting Tools Helps Businesses to Change the Operational Paradigm

    Blog in Salesforce

    In a world where work from home has become the new normal, businesses quickly need to adapt to the changing market scenario. Companies must take…

    Automated Budget Planning, Automated Workflow, Bad data, Big Data, Business Information Management
    Softweb Sep 8, 2020
    2,320  Views

    Fast Track your Marketing Activities and Enhance User Experience with DemandBlue's Salesforce Marketing Cloud Accelerators

    Blog in Salesforce Cloud Platform

    Salesforce Marketing Cloud is one of the most used digital marketing platforms. DemandBlue’s set of Marketing Cloud and Pardot accelerators are uniquely backed by a decade of…

    Automation, Automation Rules, Best Practices, Business Model, Customers
    DemandBlue May 18, 2022
    1,811  Views

    Popular Salesforce Videos

    Introduction to Salesforce CPQ | EP1

    Introduction to Salesforce CPQ | EP1

    Video in Salesforce Products

    Session 1: Introduction to Salesforce CPQ: The video provides an introduction to the general quoting challenge many Customers face, and how Salesforce CPQ with its…

    Salesforce Training, Salesforce CPQ, CPQ, Salesforce Video, Salesforce Learning
    Prafull Jan 5, 2021
    1,777  Views
    Dynamic Action in Salesforce | Salesforce Tutorial

    Dynamic Action in Salesforce | Salesforce Tutorial

    Video in Salesforce Training

    In this video, we are going to talk all about dynamic actions in Salesforce. 00:00 Introduction 00:57 Work with Dynamic Action 05:05 Dynamic Actions in…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Video, Salesforce Learning
    Prafull Aug 27, 2021
    1,303  Views
    How to Create a Connected App in Salesforce? | What is a Connected App?

    How to Create a Connected App in Salesforce? | What is a Connected App?

    Video in Salesforce Apps

    Watch this video to learn how to create a Salesforce connected app to enables an external application to integrate with Salesforce using APIs. If you…

    Salesforce Training, Salesforce Integration, salesforce, Salesforce Video, Salesforce Learning
    Pooja Jul 27, 2021
    2,082  Views

    Popular Salesforce Infographics

    How to Choose the Right CRM for Your Business?

    Infographic in Salesforce CRM

    There are many CRM solutions for companies to choose from, and wading through the wide range of options can seem like a daunting task. Choosing…

    Business Success, CRM Software, Salesforce Business Solutions, CRM Predictions, CRM 2018
    Shiv Kumar Sharma Mar 7, 2018
    3,087  Views
    salesforce productivity

    A Better Way To Manage Your Salesforce | An Infographic

    Infographic in Analytics

    New software allows sales executives to see exactly where and how sales reps spend their time. These improved analytics give management a solid basis for…

    Salesforce Development, Salesforce Deployment, Salesforce Productivity, Sales Reps, Salesforce Metadata
    Abhay Jan 3, 2018
    2,820  Views

    Salesforce Marketing Cloud

    Infographic in Salesforce Marketing Cloud

    Salesforce Marketing Cloud is a platform where relevant and personalized journeys are delivered across different devices and channels. This allows the marketers to deliver right…

    Salesforce Training, Marketing, Salesforce, Cloud, Salesforce Marketing Cloud
    Arjun Jan 22, 2020
    7,093  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

    © 2025 - 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.