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
SUMANTH ELLURUSUMANTH ELLURU 

A visualforce search page where the user can perform wild card search for candidates using their location and or skill set

A visualforce search page where the user can perform wild card search for candidates using their location and or skill set
Suraj TripathiSuraj Tripathi

Hi SUMANTH,
Below is the code for the same. It working fine in my Org. I have used it for Standard object 'Account'. I have created 2 Custom fields (Location & Skill Set).

 

Visual force page code :
<apex:page controller="Vf3Controller" >  
    <apex:form >
        <apex:outputLabel style="font-weight:bold;" value="Search By Location Or Skill set:" >
        </apex:outputLabel>
        &nbsp;<apex:inputText value="{!textData}"/>
           &nbsp;<apex:commandButton value="Search" action="{!result}"/>
        <apex:pageBlock >
              <apex:pageBlockTable value="{!acc}" var="ac">
                    <apex:column >
                        <apex:facet name="header">Name</apex:facet>
                        {!ac.Name}
                    </apex:column>
                  <apex:column >
                        <apex:facet name="header">Phone</apex:facet>
                        {!ac.Phone}
                  </apex:column>
                  <apex:column >
                        <apex:facet name="header">Billing City</apex:facet>
                        {!ac.BillingCity}
                  </apex:column>
                    <apex:column >
                        <apex:facet name="header">Postalcode</apex:facet>
                        {!ac.BillingPostalCode}
                    </apex:column>
                </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>    
</apex:page>


Apex Controller : 

public class Vf3Controller 
{
    public string textData{get;set;}
    public List<Account>acc{get;set;}
      
    public PageReference result()
    {
        acc= [Select Phone, Name, BillingPostalCode, BillingCity from Account where Location__c Like :'%'+textData+'%' OR Skill_set__c Like :'%'+textData+'%'];    
        return null; 
    }
}

Screenshots :​

User-added image

User-added image


Regard,
Suraj​

Mitchell CarlsonMitchell Carlson
Suraj,
This worked well for me. Thanks for the information! I have a question to this. How would you add a clear button that clears both the search field AND the results. I created a forum post for this: https://developer.salesforce.com/forums?id=9060G000000MTzHQAW

I have it working to clear the search field, but am stuck on the results. Let me know if you have any thoughts. I appreciate the help. 

Mitch
Suraj TripathiSuraj Tripathi

Hi Mitchell, 
Below is the Code for your requirement. Its working fine in my Org. Hopes it helps you.
I just added One more reset button and made a method for that which will clear the Account detail which from the query and the string which we searched the account.
 
Visualforce Page :
<apex:page controller="Vf3Controller" >  
    <apex:form >
        <apex:outputLabel style="font-weight:bold;" value="Search By Location Or Skill set:" >
        </apex:outputLabel>
        &nbsp;<apex:inputText value="{!textData}"/>
           &nbsp;<apex:commandButton value="Search" action="{!result}"/>
        <apex:commandButton value="Clear records" action="{!clear}" /> 
        <apex:pageBlock id="pbBlock"> 
              <apex:pageBlockTable value="{!acc}" var="ac">
                    <apex:column > 
                        <apex:facet name="header">Name</apex:facet>
                        {!ac.Name}
                    </apex:column>
                  <apex:column >
                        <apex:facet name="header">Phone</apex:facet>
                        {!ac.Phone}
                  </apex:column>
                  <apex:column >
                        <apex:facet name="header">Billing City</apex:facet>
                        {!ac.BillingCity}
                  </apex:column>
                    <apex:column >
                        <apex:facet name="header">Postalcode</apex:facet>
                        {!ac.BillingPostalCode}
                    </apex:column>
                </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>    
</apex:page>

Controller:
public class Vf3Controller 
{
    public string textData{get;set;}
    public List<Account>acc{get;set;}
      
    public PageReference result()
    {
        acc= [Select Phone, Name, BillingPostalCode, BillingCity from Account where Location__c Like :'%'+textData+'%' OR Skill_set__c Like :'%'+textData+'%'];    
        return null; 
    }
    public void clear(){ 
        this.textData='';
        acc.clear();  
    } 
}

Please mark this answer best if it resolves your query.

Regard,
Suraj​

 

SUMANTH ELLURUSUMANTH ELLURU
hi suraj,
in your code skill set is text field . but in my scenario, skill set is multi picklist. can you help me