function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jasril Dane CaliwagJasril Dane Caliwag 

Hello everyone! can someone help me out i need to filter or the picklist value based on selected value on a lookup field

Raj VakatiRaj Vakati
In visualforce ? or standard page ?
Jasril Dane CaliwagJasril Dane Caliwag
in visualforce
 
Raj ERaj E
Yes you can filter records based on a picklist or a lookup field. Your code would be something like

public class FilterLookupController {
    
    public contact con {get; set;}
    public List<contact> conlist {get; set;}
    
    public FilterLookupController() {
        conlist = new List<contact>();
        con = new contact();
    }
    
    public PageReference filter() {
        conlist = [select id,lastname,firstname,email,accountid from contact where accountid=:con.accountid];
        return null;
    }    
}

<apex:page controller="FilterLookupController">
    <apex:form >
        <b>Account :</b> <apex:inputField value="{!con.accountid}"/>
        <apex:pageblock >
            <apex:commandButton action="{!filter}" value="Filter"/>
            <apex:pageblockTable value="{!conlist}" var="c">
                <apex:column value="{!c.lastname}"/>
                <apex:column value="{!c.firstname}"/>
                <apex:column value="{!c.email}"/>
                <apex:column value="{!c.accountid}"/>
            </apex:pageblockTable>
        </apex:pageblock>
    </apex:form>
</apex:page>