File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ public class LeadQueryRepository {
2+
3+ public static Lead getLeadById (Id leadId ) {
4+ // Created a string for your where clause
5+ String whereClause = ' WHERE Id = :leadId' ;
6+ // Created a new instance of QueryGenerator, using a field set and your where clause
7+ String query = new QueryGenerator (SObjectType .Lead .FieldSets .MyFieldSet ).buildQuery (whereClause );
8+
9+ // Database.query returns generic SObjects, so cast it to the desired SObject type & return it
10+ return (Lead )Database .query (query );
11+ }
12+
13+ public static List <Lead > getLeadsByStatus (String status ) {
14+ // Created a string for your where clause
15+ String whereClause = ' WHERE Status = :status' ;
16+ // Created a new instance of QueryGenerator, using a field set and your where clause
17+ String query = new QueryGenerator (SObjectType .Lead .FieldSets .MyFieldSet ).buildQuery (whereClause );
18+
19+ // Database.query returns generic SObjects, so cast it to the desired SObject type & return it
20+ return (List <Lead >)Database .query (query );
21+ }
22+
23+ }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <ApexClass xmlns =" http://soap.sforce.com/2006/04/metadata" >
3+ <apiVersion >38.0</apiVersion >
4+ <status >Active</status >
5+ </ApexClass >
You can’t perform that action at this time.
0 commit comments