• Aathmacharan Selvasudarsanan
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
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;
    }​​​​​​​​
    
}
public class ContactAndLeadSearch {
public static List<List<SObject>> searchContactsAndLeads(string FN)
{
    List<List<sObject>> searchList = [FIND 'FN' IN all fields 
RETURNING Contact(FirstName,LastName) ,Lead(FirstName,Lastname)];
//Contact[] searchContacts = (Contact[])searchList[0];
//Lead[] searchLeads = (Lead[])searchList[1];
return searchList;
   

}
}

Please someone correct this code ,, this one was nt fulfilling the challenge req.