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

Multiple Search Controller
Hi,
I have a controller which I have used from a glorious Bob Buzzard blog:
This works perfectly, but I want to use several of these searches together on one page. The above is for a complaints object, but we have a customer feedback object and an audits object which I want to use this for. I am building a visualforce page which will become a Customer Service Team landing page and they can search across these different objects but ....
How do I add more searches onto the same controller?
Visualforce Page with duplicated search in very early stages of development:
Thanks
I have a controller which I have used from a glorious Bob Buzzard blog:
public class CSTHomeController { public String nameQuery {get; set;} public List<Complaints__c> com {get; set;} public PageReference executeSearch() { String queryStr='%' + nameQuery + '%'; com=[select id, Name, Patient_Name_Reference__c, Date_and_time_complaint_lodged__c, Complainant_Type__c from Complaints__c where Patient_Name_Reference__c like :queryStr]; return null; } public CSTHomeController () { // if query appears in URL, execute it String urlQuery=ApexPages.currentPage().getParameters().get('query'); if ( (null!=urlQuery) && (0!=urlQuery.length()) ) { nameQuery=urlQuery; executeSearch(); } } }
This works perfectly, but I want to use several of these searches together on one page. The above is for a complaints object, but we have a customer feedback object and an audits object which I want to use this for. I am building a visualforce page which will become a Customer Service Team landing page and they can search across these different objects but ....
How do I add more searches onto the same controller?
Visualforce Page with duplicated search in very early stages of development:
<apex:page controller="CSTHomeController"> <style type="text/css"> h1 { display: block; font-size: 18pt; font-family: arial; font-weight: bold; text-align: center; } </style> <h1> Customer Service Team </h1> <apex:form > <apex:pageBlock > <table> <tr> <td><apex:outputlink value="https://cs21.salesforce.com/a0C/o">Complaints Home</apex:outputlink></td> </tr> <tr> <td style="height:10px;"></td> </tr> <tr> <td><apex:outputLabel value="Search for a Complaint"/></td> </tr> <tr> <td><apex:inputText value="{!nameQuery}"/></td> </tr> <tr> <td style="height:10px;"></td> </tr> <tr> <td><apex:commandButton action="{!executeSearch}" value="Search"/></td> </tr> </table> <apex:pageBlockTable value="{!com}" var="comp"> <apex:column headerValue="Complaint Results"> <apex:outputLink value="/{!comp.id}/e?retURL={!URLENCODE('/apex/RetUrlSearchPage?query='+nameQuery)}">{!comp.Name}</apex:outputLink> </apex:column> <apex:column value="{!comp.Patient_Name_Reference__c}"/> <apex:column value="{!comp.Date_and_time_complaint_lodged__c}"/> <apex:column value="{!comp.Complainant_Type__c }"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> <apex:form > <apex:pageBlock > <table> <tr> <td><apex:outputlink value="https://cs21.salesforce.com/a0C/o">Complaints Home</apex:outputlink></td> </tr> <tr> <td style="height:10px;"></td> </tr> <tr> <td><apex:outputLabel value="Search for a Complaint"/></td> </tr> <tr> <td><apex:inputText value="{!nameQuery}"/></td> </tr> <tr> <td style="height:10px;"></td> </tr> <tr> <td><apex:commandButton action="{!executeSearch}" value="Search"/></td> </tr> </table> <apex:pageBlockTable value="{!com}" var="comp"> <apex:column headerValue="Complaint Results"> <apex:outputLink value="/{!comp.id}/e?retURL={!URLENCODE('/apex/RetUrlSearchPage?query='+nameQuery)}">{!comp.Name}</apex:outputLink> </apex:column> <apex:column value="{!comp.Patient_Name_Reference__c}"/> <apex:column value="{!comp.Date_and_time_complaint_lodged__c}"/> <apex:column value="{!comp.Complainant_Type__c }"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
Thanks
Your executeSearch method will change a bit though to accomdate muliple items, I actually found a blog post that illustrates what I was about to type up... Gotta love the community!
Check this out: http://www.sfdcpoint.com/salesforce/sosl-example-in-salesforce/ (The code from the page is below)
Page example
Controller:
All Answers
Your executeSearch method will change a bit though to accomdate muliple items, I actually found a blog post that illustrates what I was about to type up... Gotta love the community!
Check this out: http://www.sfdcpoint.com/salesforce/sosl-example-in-salesforce/ (The code from the page is below)
Page example
Controller:
Wizno @ Configero: I have added the method you suggested and it is working sporadically and not returning all searches.
Matthews: Can you offer further explanation on your suggestion.
Ben
Can any one hekp how to use multiple search in SOSL queries like.
String name{get;set;}
string email {get;set;}
List<List<SObject>> searchList = [find :companyName OR :email IN ALL FIELDS RETURNING Account (Id, Name), Contact, Opportunity, Lead];
I am getting error with the above query...