You need to sign in to do that
Don't have an account?
Balajee Selvaraj
Error: Compile Error: Method does not exist or incorrect signature: search.query(String) at line 13 column 38
My contorller is:
Public with sharing class soqlExpController{
Public List<contact> conList{get;set;}
Public List<account> accList{get;set;}
Public String Keyword{get;set;}
Public soqlExpController(){
}
Public void soslDemo_method(){
conList = New List<contact>();
accList = New List<account>();
String searchStr1 = '*'+keyword+'*';
String searchQuery = 'FIND \'' +searchStr1+ '*\' IN ALL FIELDS RETURNING Account (Id,Name,type),Contact(name,email)';
List<List <sObject>> searchList = search.query(searchQuery);
accList = ((List<Account>)searchList[0]);
conList = ((List<contact>)searchList[1]);
}
}
MY VF page is:
<apex:page controller="soqlExpController">
<apex:form >
<apex:inputText value="{!keyword}"/>
<apex:commandButton value="Show records using SOSL" action="{!soslDemo_method}"/>
<apex:pageBlock title="Accounts">
<apex:pageblockTable value="{!accList }" var="acc">
<apex:column value="{!acc.name}"/>
<apex:column value="{!acc.Type}"/>
</apex:pageblockTable>
</apex:pageBlock>
<apex:pageBlock title="Contacts">
<apex:pageblockTable value="{!conList}" var="con">
<apex:column value="{!con.name}"/>
<apex:column value="{!con.email}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Public with sharing class soqlExpController{
Public List<contact> conList{get;set;}
Public List<account> accList{get;set;}
Public String Keyword{get;set;}
Public soqlExpController(){
}
Public void soslDemo_method(){
conList = New List<contact>();
accList = New List<account>();
String searchStr1 = '*'+keyword+'*';
String searchQuery = 'FIND \'' +searchStr1+ '*\' IN ALL FIELDS RETURNING Account (Id,Name,type),Contact(name,email)';
List<List <sObject>> searchList = search.query(searchQuery);
accList = ((List<Account>)searchList[0]);
conList = ((List<contact>)searchList[1]);
}
}
MY VF page is:
<apex:page controller="soqlExpController">
<apex:form >
<apex:inputText value="{!keyword}"/>
<apex:commandButton value="Show records using SOSL" action="{!soslDemo_method}"/>
<apex:pageBlock title="Accounts">
<apex:pageblockTable value="{!accList }" var="acc">
<apex:column value="{!acc.name}"/>
<apex:column value="{!acc.Type}"/>
</apex:pageblockTable>
</apex:pageBlock>
<apex:pageBlock title="Contacts">
<apex:pageblockTable value="{!conList}" var="con">
<apex:column value="{!con.name}"/>
<apex:column value="{!con.email}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Try using System.Search.query(searchQuery) instead of search.query
Also ensure your class version is not pointing to old version of apex.