Search box for searching records in account object

Salesforce_real_time_tasks

Scenario:
          Objects having many records.If you want find a record it's too difficult,you need to search each record manually. So i created a search box using visualforce and apex controller to full fill the requirement easy.
Solution:

<apex:page standardController="account" tabStyle="account" extensions="accountsearch">
    <apex:form >
       <apex:pageBlock id="block">
            <apex:pageBlockSection title="Search" collapsible="false">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel for="searchText">Search</apex:outputLabel>
                     <apex:panelGroup >
                       <apex:inputText id="searchText" value="{!searchText}"/>
                        <apex:commandButton value="Search" action="{!search}"  status="s"/>
                        <apex:actionStatus id="s" startText="Please wait..."/>
                     </apex:panelGroup>
                 </apex:pageBlockSectionItem>
           </apex:pageBlockSection>       
       <apex:pageBlockSection title="Results" id="resultsBlock" collapsible="false" columns="1" rendered="{!NOT(ISNULL(searchResults))}">
            <apex:pagemessages />  
                 <apex:pageBlockTable value="{!searchResults}" var="acc" >             
                    <apex:column value="{!acc.name}"/>
                   <apex:column value="{!acc.billingstate}"/>
                   <apex:column value="{!acc.phone}"/>
                   <apex:column value="{!acc.website}"/>
              </apex:pageBlockTable>
        </apex:pageBlockSection>
  </apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public with sharing class accountsearch  {
 // private ApexPages.StandardController controller {get; set;}
  public List<account> searchResults {get;set;}
  public string searchText{get;set;}
  public accountsearch(ApexPages.StandardController controller) { }
  public PageReference search() {
          String qry = 'select  Name,billingstate,phone,website from account '+' where name LIKE \'%'+searchText+'%\' order by name '; 
        searchResults = Database.query(qry);
         if (searchResults.size() == 0){
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Warning,'No Accounts Found'));
       }
    return null; 
  }
}
Result:
 

COMMENTS

Name

Apex Apex Default Methods Apex Methods Apex_Collections Apps Batch Apex Books CRM eBooks Data Import Wizard Data Management DataLoader Dataloader.io Difference Between Error in Salesforce FAQ's FAQ's-Apex FAQ's-Apps FAQ's-CRM FAQ's-Data loader FAQ's-SOQL & SOSL FAQ'S-Triggers FAQ's-User Profile & Security FAQ's-VF Force.com Explorer Force.com Ide Formulas & Functions Integration Interview Questions Only Latest_Updates Limits&Best Practices Online-Training Reports and Dashboards Salesforce Deployment Salesforce Realtime Examples On Development Salesforce Realtime Task On Admin Salesforce Realtime Tasks Salesforce Realtime Tasks- Apex Salesforce Training Salesforce1 Mobile Sites SOQL Spring'14 Release Triggers User Profile & Security VF Tags VisualForce Winter'14 Release Wizard for Accounts/Contacts Workbench Workflows and Approvals
false
ltr
item
Sfdc Gurukul- All in one place for salesforce and force.com step by step tutorial for beginners: Search box for searching records in account object
Search box for searching records in account object
search box,search records,search accounts,rows search,record search in salesforce,quick find records,how to search records in salesforce,quick search,visualforce page for search records,vf page for search account records
http://2.bp.blogspot.com/-LVe9Dbk2Erg/U0vuePGdc1I/AAAAAAAABss/Mwdg9ryM5ZU/s1600/Salesforce_real_time_tasks.jpg
http://2.bp.blogspot.com/-LVe9Dbk2Erg/U0vuePGdc1I/AAAAAAAABss/Mwdg9ryM5ZU/s72-c/Salesforce_real_time_tasks.jpg
Sfdc Gurukul- All in one place for salesforce and force.com step by step tutorial for beginners
http://sfdcgurukul.blogspot.in/2013/04/search-box-for-searching-records-in.html
http://sfdcgurukul.blogspot.in/
http://sfdcgurukul.blogspot.com/
http://sfdcgurukul.blogspot.com/2013/04/search-box-for-searching-records-in.html
true
4199533888133360731
UTF-8
Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy