+ Start a Discussion
niladri_3121niladri_3121 

I am not able to bring the fields of account object in Picklist

VF

<apex:page controller="search_global">

<apex:form >

<apex:pageBlock title="Custom Search" mode="edit" id="block" >

<apex:pageBlockSection >

<apex:inputCheckbox label="Limit to accounts I own" />

<apex:pageBlockSectionItem >

<apex:outputLabel for="SearchText">Enter The Records Of Accounts

</apex:outputLabel>

<apex:panelGroup >

<apex:inputText id="searchText" value="{!searchText}"/>

<apex:commandButton value="Submit!" action="{!dosearch}" rerender="block" status="status"/>

</apex:panelGroup>

</apex:pageBlockSectionItem>

</apex:pageBlockSection>

<apex:actionStatus id="status" startText="requesting..."/>

<apex:pageBlockSection title="Results" id="results" columns="1">

<apex:pageBlockTable value="{!results}" var="l" rendered="{!NOT(ISNULL(results))}">

<apex:column value="{!l.name}"/>

<apex:column value="{!l.industry}"/>

<apex:column value="{!l.rating}"/>

<apex:column value="{!l.AccountPriority__c}"/>

</apex:pageBlockTable>

</apex:pageBlockSection>

</apex:pageBlock>

</apex:form>

</apex:page>

 

CONTROLLER

 

public class search_global {

 

String searchtext;

String newsearchtext=searchtext+'%';

 

List<account> Results;

public String getsearchtext(){

return searchtext;

}

public Boolean check{

get{

if(check== null){

check = false;

}

return check;

}

set;

}

 

public void setsearchtext(String s)

{

searchtext=s;

}

public list<account> getResults()

{

return Results;

}

public pagereference dosearch()

{

if(check==false)

{

results=[select name,Industry,Rating,AccountPriority__C from account where account.name like :searchtext+'%' or industry=:searchtext or rating=:searchtext or AccountRegion__c=:searchtext or AccountPriority__c=:searchtext or AccountSummary__c like :searchtext+'%'];

}

else

{

results=[select name,Industry,Rating,AccountPriority__C from account where (account.name like :searchtext+'%' or industry=:searchtext or rating=:searchtext or AccountRegion__c=:searchtext or AccountPriority__c=:searchtext or AccountSummary__c like :searchtext+'%')and (ownerid=:UserInfo.getUserId())];

}

return null;

}

 

}

//Upto this i got the entire fields of the record types.But my requirment is to give all those field of account record should be in a picklist.

SrishSrish

Please find the code for creating multiselect picklist. Make the necessary changes.

 

<--vf code-->
<apex:page controller="multiselectcls">
  <apex:form >        
  <apex:panelGrid columns="3" id="abcd">            
  <apex:selectList id="sel1" value="{!leftselected}" multiselect="true" style="width:100px" size="5">                
  <apex:selectOptions value="{!unselectedvalues}" />            
  </apex:selectList>                
  <apex:panelGroup >                    
  <br/>                    
  <apex:CommandButton value="  >  " action="{!selectclick}"/> <br/>
  <apex:CommandButton value="  <  " action="{!unselectclick}"/>             
  </apex:panelGroup>            
  <apex:selectList id="sel2" value="{!rightselected}" multiselect="true" style="width:100px" size="5">                
  <apex:selectOptions value="{!SelectedValues}" />            
  </apex:selectList>        
  </apex:panelGrid>    
  </apex:form>
</apex:page>
-------------------------------
//controller
public with sharing class multiselectcls
{
     Set<String> originalvalues = new Set<String>{'A','B','C','D','E','F','G'};    
     Public List<string> leftselected{get;set;}    
     Public List<string> rightselected{get;set;}    
     Set<string> leftvalues = new Set<string>();    
     Set<string> rightvalues = new Set<string>(); 
             
     public multiselectcls()
     {        
     leftselected = new List<String>();        
     rightselected = new List<String>();        
     leftvalues.addAll(originalValues);    
     }         
     public PageReference selectclick()
     {        
     rightselected.clear();        
     for(String s : leftselected)
     {            
     leftvalues.remove(s);            
     rightvalues.add(s);        
     }        
     return null;    
     }        
      public PageReference unselectclick()
      {        
      leftselected.clear();        
      for(String s : rightselected)
      {            
      rightvalues.remove(s);            
      leftvalues.add(s);        
      }        
      return null;    
      }     
      public List<SelectOption> getunSelectedValues()
      {        
      List<SelectOption> options = new List<SelectOption>();        
      List<string> tempList = new List<String>();        
      tempList.addAll(leftvalues);        
      tempList.sort();        
      for(string s : tempList)            
      options.add(new SelectOption(s,s));        
      return options;    
      }     
      public List<SelectOption> getSelectedValues()
      {        
      List<SelectOption> options1 = new List<SelectOption>();        
      List<string> tempList = new List<String>();        
      tempList.addAll(rightvalues);        
      tempList.sort();        
      for(String s : tempList)            
      options1.add(new SelectOption(s,s));        
      return options1;    
      }
}

 

 

niladri_3121niladri_3121

Thank you sir. 

Niladri Ghosh