You need to sign in to do that
Don't have an account?
Aathmacharan Selvasudarsanan
Getting This ERROR: -- Invalid identifier ''. Apex identifiers must start with an ASCII letter (a-z or A-Z) followed by any number of ASCII letters (a-z or A-Z), digits (0 - 9), '$', '_'.
public class customSearchSobjectLWC {
@AuraEnabled
public static List<Books__c> getBookById(string searchKey){
string searchKeyword = '%' + searchKey + '%';
list<Books__c> books = new list<Books__c>();
for(Books__c obj :[Select Name,Return_Date__c,Book_Status__c,Author__c,Category__c
From Books__c WHERE Name LIKE : searchKeyword]){
books.add(obj);
}
return books;
}
@AuraEnabled
public static List<Books__c> getBookByauthor(string searchKey){
string searchKeyword = '%' + searchKey + '%';
list<Books__c> books = new list<Books__c>();
for(Books__c obj :[Select Name,Return_Date__c,Book_Status__c,Author__c,Category__c
From Books__c WHERE Author__c LIKE : searchKeyword]){
books.add(obj);
}
return books;
}
@AuraEnabled
public static List<Books__c> getBookBycategory(string searchKey){
string searchKeyword = '%' + searchKey + '%';
list<Books__c> books = new list<Books__c>();
for(Books__c obj :[Select Name,Return_Date__c,Book_Status__c,Author__c,Category__c
From Books__c WHERE Category__c LIKE : searchKeyword])
{
books.add(obj);
}
return books;
}
}
@AuraEnabled
public static List<Books__c> getBookById(string searchKey){
string searchKeyword = '%' + searchKey + '%';
list<Books__c> books = new list<Books__c>();
for(Books__c obj :[Select Name,Return_Date__c,Book_Status__c,Author__c,Category__c
From Books__c WHERE Name LIKE : searchKeyword]){
books.add(obj);
}
return books;
}
@AuraEnabled
public static List<Books__c> getBookByauthor(string searchKey){
string searchKeyword = '%' + searchKey + '%';
list<Books__c> books = new list<Books__c>();
for(Books__c obj :[Select Name,Return_Date__c,Book_Status__c,Author__c,Category__c
From Books__c WHERE Author__c LIKE : searchKeyword]){
books.add(obj);
}
return books;
}
@AuraEnabled
public static List<Books__c> getBookBycategory(string searchKey){
string searchKeyword = '%' + searchKey + '%';
list<Books__c> books = new list<Books__c>();
for(Books__c obj :[Select Name,Return_Date__c,Book_Status__c,Author__c,Category__c
From Books__c WHERE Category__c LIKE : searchKeyword])
{
books.add(obj);
}
return books;
}
}
There were some extra characters in some lines. I have modified the code as below. Please try using this
If this solution helps, Please mark it as best answer.
Thanks,