+ Start a Discussion
Bablu Kumar PanditBablu Kumar Pandit 

How to impliment search functionlity in vf page

for exapmle if user enter details in search box and click on search button then if any name realed to account are avilable then ll the details of that Account
how to i impiment guide me
AbhishekAbhishek (Salesforce Developers) 

Please refer to the below code for reference on Search Functionality.

VisualForce Page:

<apex:page controller="Searchname">
  <apex:form >
  <apex:PageBlock >
  <apex:PageBlockSection >
  <apex:PageBlockSectionItem >
  <apex:outputLabel > Name</apex:outputLabel>
  <apex:inputText value="{!name}"/>
  <apex:commandButton value="Go" action="{!executeSearch}"/>
  <apex:PageBlockTable var="act" value="{!mycar}"> 
  <apex:column value="{!act.name}"/>  
  <apex:column value="{!act.Price__c}"/>
  <apex:PageBlock >
  <!--apex:commandButton value="Edit" action="{!edit}"/-->

Apex Class:

public with sharing class Searchname {
     public String name { get; set;}
    public list<car__c> mycar { get; set; }
    public boolean searched{get;set;}
    public searchname() {
    string namestr=ApexPages.currentPage().getParameters().get('name');
    if(null!=namestr) {
    public PageReference executeSearch() {
    System.debug('name' +name);
    string searchstr=('%'+name+'%');
   // accounts= new List<Account>();
    mycar=[select id,Name,price__c from car__c where name Like:searchstr limit 20];
        return null;

For further reference, you can check the below blog,


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Bablu Kumar PanditBablu Kumar Pandit
Hii Abhishekh ,

I already tried this links ,i want that when Any Recode avilabe In the Org Realted to Account name Then we want to display Recode Detail page of that Account