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
Hiral Patel 25Hiral Patel 25 

// Write an APEX Program to fetch All Lead Records, Based on the Lead status Supplied by the User at Run-Time

 // Write an APEX Program to fetch All Lead Records, Based on the Lead status Supplied by the User at Run-Time
 
AnudeepAnudeep (Salesforce Developers) 
public class Fetch_Leads{
        public static List<Lead> query(String field, String values){ List<String> statuses = values.split(';'); 
return Database.query('SELECT Id, FROM Lead WHERE '+field+' IN:statuses'); }
    }
Providing here a sample code
Reddy RakeshReddy Rakesh
Hi Hiral,

public class Fetch_Leads{
public static List<lead> getleads(string statusGivenbyUser){
List<lead> leadList = [SELECT Id, LastName, MiddleName, Title, Industry, Status__c FROM Lead WHERE status__c=:statusGivenbyUser];
return leadList;
}
}
Dinesh Singh 62Dinesh Singh 62
public class Fetch_Leads{ public static List<Lead> query(String field, String values){ List<String> statuses = values.split(';'); return Database.query('SELECT Id, FROM Lead WHERE '+field+' IN:statuses'); } }, Regards - doctor kaise bane (https://www.niodemy.com/doctor-kaise-bane/)