You need to sign in to do that
Don't have an account?

search bar to show the results if they contains a word in apex
Hi everyone,
I have created a search bar(ProjectSearch) in VF page to show the records in the page based on the result for a specific field(Project_ID__C), but right now it showes the results if I put the exact value of that field(Project_ID__C), while I need it to show the results if I just enter a part of the value of that field(Project_ID__C). please advise:
stdSetCont = new ApexPages.StandardSetController(Database.getQueryLocator([Select id,,Project_ID__c from Charts__c where Project_ID__c =: ProjectSearch and HRS_Site_ID__c =: ApexPages.CurrentPage().getParameters().get('hrsId') Limit 10000]));
I have created a search bar(ProjectSearch) in VF page to show the records in the page based on the result for a specific field(Project_ID__C), but right now it showes the results if I put the exact value of that field(Project_ID__C), while I need it to show the results if I just enter a part of the value of that field(Project_ID__C). please advise:
stdSetCont = new ApexPages.StandardSetController(Database.getQueryLocator([Select id,,Project_ID__c from Charts__c where Project_ID__c =: ProjectSearch and HRS_Site_ID__c =: ApexPages.CurrentPage().getParameters().get('hrsId') Limit 10000]));
ProjectSearch = '%' + ProjectSearch + '%';
stdSetCont = new ApexPages.StandardSetController(Database.getQueryLocator([Select id,,Project_ID__c from Charts__c where Project_ID__c like :ProjectSearch and HRS_Site_ID__c =: ApexPages.CurrentPage().getParameters().get('hrsId') Limit 10000]));
==========
ps: If your question/problem is resolved, please mark your post as 'Solved' so that community can benefit from solutions.
All Answers
ProjectSearch = '%' + ProjectSearch + '%';
stdSetCont = new ApexPages.StandardSetController(Database.getQueryLocator([Select id,,Project_ID__c from Charts__c where Project_ID__c like :ProjectSearch and HRS_Site_ID__c =: ApexPages.CurrentPage().getParameters().get('hrsId') Limit 10000]));
==========
ps: If your question/problem is resolved, please mark your post as 'Solved' so that community can benefit from solutions.