Skip to content

Commit

Permalink
Merge pull request #7 from wasef237/patch-1
Browse files Browse the repository at this point in the history
Update SearchController.cls - SOSL Fix
  • Loading branch information
amitastreait authored Dec 7, 2024
2 parents 4ee7973 + 771bf9c commit c00e2e5
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions sfdxsrc/customLookup/classes/SearchController.cls
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* @description :
* @description :
* @author : Amit Singh
* @group :
* @last modified on : 12-21-2021
* @last modified by : Amit Singh
* @group :
* @last modified on : 05-12-2024
* @last modified by : Wasef Mohiuddin
**/
public with sharing class SearchController {
@AuraEnabled
Expand All @@ -18,7 +18,14 @@ public with sharing class SearchController {
String soqlQuery = 'SELECT Id, Name, Type, LastViewedDate FROM RecentlyViewed WHERE Type =\''+objectName+'\' ORDER BY LastViewedDate DESC LIMIT 5';
sobjList = Database.query( soqlQuery );
searchRecords.add(sobjList);
}else{
}
//Since SOSL has a minimum limit, included this for the first couple characters, as it was giving errors
else if(searchTerm.length()<3){
String soqlQuery = 'SELECT Id, '+String.join(fields,',')+' FROM '+objectName+' WHERE Name LIKE \'%'+searchTerm+'%\' LIMIT 5';
sobjList = Database.query( soqlQuery );
searchRecords.add(sobjList);
}
else{
searchRecords = Search.Query(Query);
}
return searchRecords.get(0);
Expand All @@ -36,4 +43,4 @@ public with sharing class SearchController {
}
return createdRecord;
}
}
}

0 comments on commit c00e2e5

Please sign in to comment.