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
pavan kumar 1156pavan kumar 1156 

Creating a Custom pick list

when user select an account from the picklist, all opportunities which are related to that account should be displayed in a table with checkbox in a first column of each row, there should be one master checkbox in the header of the table to select or deselect all opportunities in one click.
Sorna JenefaSorna Jenefa

Refer this link:


Hope this helps.

Sweet Potato Tec
Ajay K DubediAjay K Dubedi
Hi Pavan
 try this code
 <apex:page controller="accountfiltercon">
    <apex:form >
        <apex:pageBlock title="Accounts">
                Account Name</h5>
            <apex:selectList size="1" value="{!selectedname}"> 
                <apex:selectOptions value="{!selectedaccnamefields}"/>
                <apex:actionSupport event="onchange" action="{!showOpps}" reRender="ListOpp">
                    <apex:param value="{!selectedname}" assignTo="{!AccName}" />
        <div class="slds-m-top_xx-large"></div>
        <apex:outputPanel id="ListOpp"  >
             <apex:pageMessages id="showmsg"></apex:pageMessages>
            <apex:pageBlock title="Account's opportunity" rendered="{!showHide}">
                <apex:pageBlockTable value="{!wrapperAccList}" var="opp">
                    <apex:column >
                        <apex:facet name="header">
                            <apex:inputCheckbox id="mainBox" value="{!mainBoxValue}" >
                                <apex:actionSupport event="onclick" action="{!checkUncheckAll}" reRender="ListOpp"/>
                        <apex:inputCheckbox value="{!opp.flag}"/>
                    <apex:column headerValue="Name" value="{!opp.oppObj.Name}"/>
                    <apex:column headerValue="Stage" value="{!opp.oppObj.StageName}"/>
                    <apex:column headerValue="Close Date" value="{!opp.oppObj.closeDate}"/>

public class accountfiltercon {
    Public string selectedname{get;set;}
    Public String AccName {get;set;}
    Public List<Opportunity> oppList {get;set;}
    public boolean showHide {get;set;}
    public List<checkBoxWrapper> wrapperAccList{get;set;}
    public Boolean mainBoxValue {get;set;}
    Public List<Selectoption> getselectedaccnamefields(){
        List<Selectoption> lstnamesel = new List<selectoption>();
        lstnamesel.add(new selectOption('', '- None -'));
        for(Account acc :[SELECT id,name,phone,type,industry FROM Account]){
            lstnamesel.add(new selectoption(,;
        return lstnamesel; 
    public void showOpps(){
        if(selectedname!=null && (selectedname.length()==15 || selectedname.length()==18)){
            wrapperAccList = new List<checkBoxWrapper>();
            for(Opportunity opp :[select Name,StageName,CloseDate from Opportunity where AccountId=:selectedname]){
                wrapperAccList.add(new CheckBoxWrapper(false,opp));
            if(wrapperAccList.size() > 0){
                showHide =true;
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'This Account Opportunity Not avalaible'));
    public void checkUncheckAll(){
        for(CheckBoxWrapper wrapObj : wrapperAccList){
            wrapObj.flag = mainBoxValue;
    public class CheckBoxWrapper{
        public Boolean flag{get;set;}
        public Opportunity oppObj{get;set;}
        public CheckBoxWrapper(Boolean flagValue,Opportunity oppObj){
            this.flag = flagValue;
            this.oppObj = oppObj;

if you found this answer helpful then please mark it as best answer so it can help others.

Ajay Dubedi