You need to sign in to do that
Don't have an account?
Muhammad Jawwad 16
How to write 2 queries in batch apex 1 for lead and another for opportunity object?
global class LoanOfficerBatch implements Database.Batchable<sObject> { public String query = 'SELECT Loan_Officer_1a__c,Loan_Officer_1a__r.Email, Name, Phone, Starting_Credit_Score__c, ' + 'Status, Enrolled_On__c, Est_Re_Pull_Date__c, Realtor_Name__c ' + ' FROM Lead'; opportunity???? public EmailTemplate templateId = [Select Id,HtmlValue,Subject from EmailTemplate where name = 'LoanOfficerRecord' LIMIT 1]; global Database.QueryLocator start(Database.BatchableContext bc) { query += ' WHERE CreatedDate >= LAST_MONTH AND CreatedDate <= THIS_MONTH AND Loan_Officer_1a__c != null'; return Database.getQueryLocator(query); }
Raj Vakati
You can do it like this ..
- Create a Constructor which will accept the object name
- Assign the Object Name variable to Global Variable
- Check if the object name is Opp or Lead then execute the SOQL queries
Raj Vakati
LIke this
Muhammad Jawwad 16
Okay after the i'm trying to fetch opportunity table above lead table in same email templete please review the code and give a me a solution?
Raj Vakati
Your code is good and now change the logic in execute method like below based on object ..