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
phani_mphani_m 

how to perform search inputtext values with sobject

haiii..................

 

 

 i created one visualforce page such that it consists of

 

                                           1,skillset_________                     <-------------by entering values in these fields

                                            2,keywords______________

                                            3,experience__________

                                        _______

                                       |   search  | <----------------By clicking on search  i need to get the records present on the standard object (applicant)... what i need to do .is there any sample code..

 

 

can any one help urgent

 

Thiyagarajan SelvarajThiyagarajan Selvaraj

Hi,

 

You can modify the below code as per your requirements

 

Visualforce

<apex:page standardController="applicant__c" extensions="clsApplicants" >
    <apex:form >
      <apex:pageBlock id="demoid" title="Demo Block"  >
          <apex:pageBlockbuttons >
              <apex:commandButton value="Search" action="{!Applicants}" />
          </apex:pageBlockbuttons>
          Skillset   <apex:inputField value="{!applicant__c.Skillset_c}" />
          Keywords   <apex:inputField value="{!applicant__c.Keywords__c}" />
        Experience <apex:inputField value="{!applicant__c.Experience__c}" />
          
          <apex:repeat value="{!applicantList}" var="a" rendered="{!applicantList.size > 0}" >
              <apex:outputText value="{!a.Name}" />
          </apex:repeat>
 
      </apex:pageBlock>
    </apex:form>
</apex:page>


Apex Code

public with sharing class clsApplicants {
    
    public ApexPages.StandardController con               {get; set;}
    public List<applicant__c>            applicantList     {get; set;}
    
    
    public clsApplicants(ApexPages.StandardController controller){
        con = controller;
    }
    
    public PageReference Applicants(){
        applicant__c app = (applicant__c)con.getRecord();
        applicantList = new List<applicant__c>();
        
        // Get the search String
        String searchString = app.Skillset_c+' OR '+app.Keywords__c+' OR '+app.Experience__c;
        
        // SOSL
        List<List<sObject>> results = [FIND:searchString IN ALL FIELDS RETURNING applicant__c(Id) LIMIT 200];
        
        // Get the applicant Ids
        Set<Id> recordIds = new Set<Id>();
        for (sObject obj : results[0]){
            recordIds.add(obj.Id);
        }
        
        // GET the applicant records
        sectionList = [SELECT Id, Name FROM applicant__c WHERE Id IN:recordIds];
        
        
        return null;
    }
   
   
   If you are using apex:inputText, pass the input value to the controller using input hidden to create a searchString