function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Komal DhimanKomal Dhiman 

Error: Compile Error: unexpected token: RETURNING at line 3 column 34

Code:
public class ContactAndLeadSearch{
    public static List<List<SObject>> searchContactsAndLeads(String name){
       return [FIND :name IN Name RETURNING Leads(Name),Contact(FirstName,LastName)];
    }
}
I am just trying to return Lead and Contact object where name contains the string passed to this method.
Best Answer chosen by Komal Dhiman
RatanRatan
Use below snippet :
public class ContactAndLeadSearch{
    public static List<List<SObject>> searchContactsAndLeads(String name){
       return [FIND :name IN Name Fields RETURNING Lead(FirstName, LastName),Contact(FirstName,LastName)];
    }
}

 

All Answers

RatanRatan
Use below snippet :
public class ContactAndLeadSearch{
    public static List<List<SObject>> searchContactsAndLeads(String name){
       return [FIND :name IN Name Fields RETURNING Lead(FirstName, LastName),Contact(FirstName,LastName)];
    }
}

 
This was selected as the best answer
Komal DhimanKomal Dhiman
Thank you so much ratan for your help.
This worked for me.