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
Michael Hedrick 2Michael Hedrick 2 

VF Page Look up or filter picklist

Hello,
 I have the following Class and VF Page below.
 
Public with sharing class AccountDealerDashboardController {

    public Id selectedAccId{get;set;} 

    public String fieldValue {get; set;}
    public String selectedFields{get;set;}
    public String JDEValue {get; set;}
    public String selectedJDE{get;set;}
    public boolean showPanel { get; set; } //to show and hide graph
    public boolean showButton { get; set; } //to show and hide button
    
    public AccountDealerDashboardController (ApexPages.StandardController stdController)
    {
        showButton = false; // onload don't display button and panelGrid
        showPanel = false;
    }

    public void accountNameChanged()
    {
        valueSelectedShowButton();
        passValueToController();
    }
    
    public void valueSelectedShowButton() 
    {
        showButton = true;// after selecting value f
    }

   
    public List<SelectOption> getAccountNames() 
        {
            List<SelectOption> accOptions= new List<SelectOption>();
            system.debug(selectedAccId);
            
            accOptions.add( new SelectOption('','--Select--'));
            for(Account acc : [select Id,name,Site,JDE__c,Status__c from Account Where Status__c = 'Active' AND Partner_Type__c='Dealer' AND Indirect_Sales_YTD__c > 10 AND OwnerId =:UserInfo.getUserid() order by Name asc] ) 

        {
            accOptions.add(new SelectOption(acc.Id,acc.name));
           
        }
            return accOptions;
        }
  
    public void passValueToController()
        {
            fieldValue = selectedFields;
            JDEValue =selectedJDE;
            
        }
  
   public void commandButtonClick()     
        {
            showPanel = true; //on click of button show panel
        }
   
  }

<apex:page standardController="Account" standardStylesheets="true"  showHeader="True" sidebar="false" extensions="AccountDealerDashboardController" >
  
    <style>
        #col1,#col2{width:15%;display:inline-block;vertical-align:Top;}
    </style>
    
    <apex:form >
        <div id="col1">
        <apex:pageBlock title="Select Account">    
            <apex:outputpanel id="Outputtext"  >
        <!--    <apex:outputtext value="{!fieldValue}"/>  -->
            </apex:outputpanel>
            <apex:selectList value="{!selectedFields}" title="Select an Account from the DropDown List" size="1" style="width:100%">
                <apex:actionSupport event="onchange"  reRender="buttonId" action="{!accountNameChanged}"/>     <!-- after selecting value in picklist set showButton to true. rerender pageBlock "buttonId" so button will be rerendered-->         
                <apex:selectOptions value="{!AccountNames}" />
              
            </apex:selectList><br/><br/>   
                <apex:outputtext value="{!fieldValue}"/>   
                <br/> 
               
        </apex:pageBlock>  
       
         
    <apex:pageBlock id="buttonId">  
        <apex:commandButton value="Show Charts" rendered="{!showButton}" title="Click Show Charts button to load reports" alt="tooltip"  action="{!commandButtonClick}" / > <!--onclick button show graph panel    reRender="chart" --> 
            <br/> 
  <!--        <apex:outputText value="{!fieldValue}" label="You have selected:" id="values" /> <!--  used to verify Id -->    
    </apex:pageBlock>  

    </div>


        <div id="col2">
        <apex:outputPanel id="chart" rendered="{!showPanel}">
        
                  <apex:panelGrid columns="3" id="theGrid" rendered="{!showPanel}">
                    <analytics:reportChart showRefreshButton="false" reportId="123456" filter="[{column:'ACCOUNT_ID',operator:'equals',value:'{!fieldValue}'}]" size="medium"> </analytics:reportChart>
                    <analytics:reportChart showRefreshButton="false" reportId="123456" filter="[{column:'ACCOUNT_ID',operator:'equals',value:'{!fieldValue}'}]" size="medium"> </analytics:reportChart>
                    <analytics:reportChart showRefreshButton="false" reportId="123456" filter="[{column:'ACCOUNT_ID',operator:'equals',value:'{!fieldValue}'}]" size="medium"> </analytics:reportChart>
                    <analytics:reportChart showRefreshButton="false" reportId="123456" filter="[{column:'ACCOUNT_ID',operator:'equals',value:'{!fieldValue}'}]" size="medium"> </analytics:reportChart>
                    <analytics:reportChart showRefreshButton="false" reportId="123456" filter="[{column:'ACCOUNT_ID',operator:'equals',value:'{!fieldValue}'}]" size="medium"> </analytics:reportChart>
                    <analytics:reportChart showRefreshButton="false" reportId="123456" filter="[{column:'ACCOUNT_ID',operator:'equals',value:'{!fieldValue}'}]" size="medium"> </analytics:reportChart>
                    <analytics:reportChart showRefreshButton="false" reportId="123456" filter="[{column:'ACCOUNT_ID',operator:'equals',value:'{!fieldValue}'}]" size="medium"> </analytics:reportChart> 
                    <analytics:reportChart showRefreshButton="false" reportId="123456" filter="[{column:'ACCOUNT_ID',operator:'equals',value:'{!fieldValue}'}]" size="medium"> </analytics:reportChart>              
              </apex:panelGrid>
       
      </apex:outputPanel> 
     </div>
    </apex:form>
    
</apex:page>

My question is how can I add an additional required field to the VF page that will determine qhick query to call that will populate the Picklist field.
for example:
The user select option 'A' on teh VF page.
The query would be:
Account acc : [select Id,name,Site,JDE__c,Status__c from Account Where Status__c = 'Active' AND Partner_Type__c='Dealer' AND Indirect_Sales_YTD__c > 10 AND OwnerId =:UserInfo.getUserid() order by Name asc] )
But if the user selects option 'B' the query would be 
Account acc : [select Id,name,Site,JDE__c,Status__c from Account Where Status__c = 'Active' AND Partner_Type__c='Contractor' AND Indirect_Sales_YTD__c > 50 AND OwnerId =:UserInfo.getUserid() order by Name asc] )

Or would it it be better to use a Lookup.
I had to use the OwnerId =:UserInfo.getUserid() becasue I was returning over 1000 records.

Any suggestion would be appreciated.
 
Thanks,
M