Through the constructor of the Batch class you can do that..i.e if your class is DemoBatch. In the batch class define a List and assign in the Constructor When you will create instanace of batch.. you can do something like..
global class DemoBatch implements Database.batchable<sObject>{ global List<sObject> myList; global DemoBatch(List<sObject> objList){ myList = objList; }
} ---------------- DemoBatch db = new DemoBatch(objList); db.executeBatch(db);
But you can pass the query string and you can query in the start method.
Through the constructor of the Batch class you can do that..i.e if your class is DemoBatch. In the batch class define a List and assign in the Constructor When you will create instanace of batch.. you can do something like..
global class DemoBatch implements Database.batchable<sObject>{ global List<sObject> myList; global DemoBatch(List<sObject> objList){ myList = objList; }
} ---------------- DemoBatch db = new DemoBatch(objList); db.executeBatch(db);
But you can pass the query string and you can query in the start method.
global class DemoBatch implements Database.batchable<sObject>{
global List<sObject> myList;
global DemoBatch(List<sObject> objList){
myList = objList;
}
}
----------------
DemoBatch db = new DemoBatch(objList);
db.executeBatch(db);
But you can pass the query string and you can query in the start method.
All Answers
global class DemoBatch implements Database.batchable<sObject>{
global List<sObject> myList;
global DemoBatch(List<sObject> objList){
myList = objList;
}
}
----------------
DemoBatch db = new DemoBatch(objList);
db.executeBatch(db);
But you can pass the query string and you can query in the start method.