I have a Batch Apex which is invoked from process builder. I can see Ids are coming into the variable (please see debug log) but same variable inside the query gives "Variable does not exist" error. I am not sure what am i doing wrong here??
public class CaseSetOwnerBatch implements Database.Batchable<sObject> {
List<String> csIds;
public CaseSetOwnerBatch(List<String> csIds) {
this.csIds = csIds;
}
@InvocableMethod(label='Set Owner to Parent Case Owner' description='This method will be execute CaseSetOwnerBatch')
public static void executeBatchMethod(List<Id> caseIds) {
System.debug('Case Ids: -- -- '+caseIds);
CaseSetOwnerBatch setOwner = new CaseSetOwnerBatch(caseIds);
Database.executeBatch(setOwner,1);
}
public static Database.QueryLocator start(Database.BatchableContext BC) {
String query = 'SELECT Id, OwnerId, LastModifiedById FROM Case WHERE Id IN :csIds';
return Database.getQueryLocator(query);
}
public void execute(Database.BatchableContext BC, List<Case> csList) {
for (Case c : csList) {
c.OwnerId = c.LastModifiedById;
}
TriggerHandler.bypass('CaseTriggerHandler');
Database.update(csList, false);
}
public void finish(Database.BatchableContext BC) {
}
}