I am writing a code that filters records who has the value of 2 fields**(Firstname__c,Lastname__c)** concatenation. I assigned that concatenation value in a string and I use contains method . But it returns nothing. Will you help me implement this code ?. for example this line of code will return String [SELECT Id,First_Name__c,Last_Name__c,Ticket_Number__c FROM Ticket__c WHERE Event__c =:Event] an array values of {firstname:martin lastname:johnson,firstname:marvin lastname: jhon,firstname:peter lastname:blair}.Using this code String fullname = String.valueOf(obj.First_Name__c)+' '+String.valueOf(obj.Last_Name__c); it will concatenate the firstname and lastname values. then my Searchkey variable contains "MA" .. it will filter and assigned the ticket_number__c of (martin and marvin) into the List filtered by this code filtered.add(obj.Ticket_Number__c);
HERE IS MY CODE
@AuraEnabled
public static List<Ticket__c> SAETH(String Searchkey,String Event){
List<String> filtered = new List<String>();
for(Ticket__c obj : [SELECT Id,First_Name__c,Last_Name__c,Ticket_Number__c FROM Ticket__c WHERE Event__c =:Event])
{
String fullname = String.valueOf(obj.First_Name__c)+' '+String.valueOf(obj.Last_Name__c);
if(fullname.contains(Searchkey))
{
filtered.add(obj.Ticket_Number__c);
}
}
System.debug(filtered);
return [SELECT Id, Name, Event_Product__c,First_Name__c,Last_Name__c,Ticket_Number__c, (SELECT Id, Check_In__c, Check_Out__c, Status__c FROM Ticket_Logs__r ORDER BY CreatedDate DESC LIMIT 1 ) FROM Ticket__c t WHERE Ticket_Number__c IN:filtered];
}