You need to sign in to do that
Don't have an account?

I want to update lead owner to XYZ when lead owner is inactive before for loop starts
global class BirthdayCard implements Database.Batchable<sObject> {
global Database.QueryLocator start(Database.BatchableContext bc)
{
return Database.getQueryLocator([SELECT OwnerId,DOB_Formula__c,Id,Possible_Followup_Date__c FROM Lead WHERE DOB_Formula__c = NEXT_N_DAYS:7 AND Possible_Followup_Date__c != null]);
}
global void execute(Database.BatchableContext bc, List<Lead> scope)
{
List<Task> listOfTask = new list<Task>();
for(Lead l : scope)
{
Task B = new Task();
B.Subject= 'Send Birthday Card';
B.ActivityDate = date.today();
B.OwnerId = l.OwnerId;
B.WhoId=l.Id;
listOfTask.add(B);
global Database.QueryLocator start(Database.BatchableContext bc)
{
return Database.getQueryLocator([SELECT OwnerId,DOB_Formula__c,Id,Possible_Followup_Date__c FROM Lead WHERE DOB_Formula__c = NEXT_N_DAYS:7 AND Possible_Followup_Date__c != null]);
}
global void execute(Database.BatchableContext bc, List<Lead> scope)
{
List<Task> listOfTask = new list<Task>();
for(Lead l : scope)
{
Task B = new Task();
B.Subject= 'Send Birthday Card';
B.ActivityDate = date.today();
B.OwnerId = l.OwnerId;
B.WhoId=l.Id;
listOfTask.add(B);
Some leads have inactive owners so for them I want to assign 'XYZ' owner and leads which have active owners they should remain as it is. After that I want to go inside my 'for' loop.
Anudeep