Code Snippet: public class BatchForOpportunities implements Database.Batchable, Database.AllowsCallouts, Database.Stateful { public Integer count = 0; public Database.QueryLocator start(Database.BatchableContext context){ System.debug('Start Method called'); String baseQuery = 'SELECT Id, Name, StageName FROM Opportunity '; String filterQuery = 'WHERE StageName = \'Perception Analysis\' AND CloseDate < LAST_N_DAYS:7'; String finalQuery = baseQuery + filterQuery; return Database.getQueryLocator(finalQuery); } public void execute(Database.BatchableContext context, List scope){ //do all the hard work here for(Opportunity opp : scope){ count++; System.debug(count); } } public void finish(Database.BatchableContext context){ //post processing logic here System.debug('Finish method called' + count); } }
@haribabuk516220 күн бұрын
Batch Job makes Sense
@salesforcemakessense20 күн бұрын
Yay!
@sumitB-h8t20 күн бұрын
YES we are on the RIGHT TRACK..☺😅
@salesforcemakessense20 күн бұрын
Awesome!
@ravigrover192320 күн бұрын
Start Method ran once Execute 10 times FInish also ran once
@salesforcemakessense20 күн бұрын
That's right.
@thesalesforceseeker21 күн бұрын
what about database.iterable ?
@salesforcemakessense20 күн бұрын
Iterables work similar to QueryLocator, just that there's no upper limit to the number of records that can be queried via an Iterator. However, CPU time limit does have an upper limit. But most of the times, queryLocator works fine and you can get used to it without doubt.