• uttam jaishwal 8
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi Folks, 
Error : Method does not exist or incorrect signature: void query(String) from the type Search at line 12 column 45    

Please help me. 

Apex Class: -

public with sharing class TestSOSLController {
Public List<account> accList{get;set;} 
 Public String searchStr{get;set;}
   Public TestSOSLController(){
   }
  
  Public void soslDemo_method(){
   accList = New List<account>();
   if(searchStr.length() > 1){
   String searchStr1 = '*'+searchStr+'*';   
   String searchQuery = 'FIND \'' + searchStr1 + '\' IN ALL FIELDS RETURNING  Account (Id,Name,Type,Rating,Phone)';
   List<List <sObject>> searchList = search.query(searchQuery);
   accList = ((List<Account>)searchList[0]);
   
   if(accList.size() == 0){
       apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Sorry, no results returned with matching string..'));
       return;
   }
   }
   else{
   apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Please enter at least two characters..'));
   return;
   }
  }
}

  • January 02, 2018
  • Like
  • 0