You need to sign in to do that
Don't have an account?
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
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