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

    5 Benefits of Salesforce for Insurance

    Blog in Salesforce integration

    When it comes to insurance CRM, Salesforce enjoys massive popularity, and deservedly so. Salesforce goes beyond the typical CRM functionalities and offers out-of-the-box capabilities. It…

    Automation, Benefits, Business Growth, Business Insights, Capabilities
    Faheem Jun 6, 2023
    1,559  Views
    runAs Method

    Using the runAs Method in Salesforce | Apex Developer Guide

    Blog in Salesforce Apex

    By and large, all Apex code runs in framework mode, where the authorizations and record sharing of the current client are not considered. The framework…

    Bundle Rendition, Client Permit, Client Set, data, DML
    rajesh andani Nov 3, 2021
    6,075  Views
    Salesforce Integration Services

    Leverage Salesforce Integration Services to Retain Valuable Customers

    Blog in Salesforce integration

    We all have heard that integrating Salesforce with other applications provides organizations much greater operational visibility and access to unknown resources. It offers innovative products…

    Applications, Basecamp, Books, Business, Business Complexities
    Technosip Aug 17, 2021
    2,946  Views

    Popular Salesforce Videos

    How to Delete Preloaded Sample Data in New Salesforce Organizations

    How to Delete Preloaded Sample Data in New Salesforce Organizations

    Video in Salesforce Training

    When Users begin a trial or subscription with Salesforce, their org comes with a set of sample data. This data includes Accounts, Contacts, and Opportunities.…

    salesforce, Salesforce Video, Salesforce Learning, Salesfore Training, Data
    Jogender May 25, 2021
    3,636  Views
    Google Home Assistant Integration with Salesforce

    Google Home Assistant Integration with Salesforce

    Video in Salesforce Integration

    Check out the below link for pdf view. https://www.linkedin.com/pulse/google-home-assistant-integration-salesforce-rajkiran-dewara/

    Salesforce Integration, salesforce, Salesforce Users, Google Home Assistant
    Rajkiran Jan 23, 2020
    4,573  Views
    Einstein For Marketing Cloud | The Learning Guide

    Einstein For Marketing Cloud | The Learning Guide

    Video in Others

    AI has made things easy and smooth for any automation process. Einstein for Marketing Cloud provides insights and data to inform the content and timing…

    CRM, Salesforce Einstein, Marketing Automation, Salesforce Marketing Cloud, Marketing Cloud
    Cyntexa Feb 9, 2023
    1,506  Views

    Popular Salesforce Infographics

    Sneak Peek: Latest Features And Updates of Salesforce commerce Cloud

    Infographic in Others

    Here is an infographic of the Latest Features And Updates of Salesforce commerce Cloud

    Salesforce Sales Cloud, Salesforce Cloud Platform, Salesforce Integration, Salesforce platform, Salesforce Customization
    lavish May 3, 2019
    3,635  Views

    10 Common Salesforce Mistakes—and How to Avoid Them

    Infographic in Salesforce integration

    Salesforce integration is challenging if you don’t know exactly what you’re getting into. It’s an enormously valuable project, but diving into it without proper understanding…

    Salesforce App Development, Salesforce Development, Salesforce Productivity, Salesforce Developers, Salesforce Data Management
    Jogender Mar 26, 2018
    3,846  Views
    Salesforce Implementation

    A Four-step Formula for Salesforce Implementation

    Infographic in Salesforce Implementation

    No matter how big or small your company—or the Salesforce CRM project—success requires planning, commitment, and strong sponsorship from your company’s executive team. It’s also…

    Salesforce, Salesforce Implementation, Salesforce Infographic, Infographic, Salesforce Learning
    Prafull Jan 6, 2022
    3,213  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.