You need to sign in to do that
Don't have an account?
Jefferson Escobar
Where should I define the query in Apex batch, in the scheduled class or in the apex batch class?
Hi,
I have a apex batch that is execueted from Schedulre class. Curently I am passing the query from the schduled class in order to limit the records in the test class but I am not sure where is the best place to declare the query, what would be the best practie ? or Where should I declare the query, in the schedulable class or directly in the apex batch adding a filter as global variable ?
Thanks for you help,
Jeff
I have a apex batch that is execueted from Schedulre class. Curently I am passing the query from the schduled class in order to limit the records in the test class but I am not sure where is the best place to declare the query, what would be the best practie ? or Where should I declare the query, in the schedulable class or directly in the apex batch adding a filter as global variable ?
Thanks for you help,
Jeff
So you can try exmple 2.
All Answers
You can define the query in two places
1) One in Batch job start method.
2) Or you can define the query in schedule also also,
Exampe 1:- Query inside batch job
Example 2:-
To execute above batch job you need to pass query inside scheduler class or in developer console.
Please check below post for more detail:-
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm
Please mark this as solution if this will help you. So that if some one has same issue this post can help others.
Thanks
Amit Chaudhary
So you can try exmple 2.