function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rajesh AnnamRajesh Annam 

Can we call finish() method from outside(seperately)

Hi All,
           Can we call finish() method which is part of batch process from outside seperately by creating instance for the class that provide implimentation for all methods in batchable interface. Please provide some valueble information on this. Thanks in advance.
ManojjenaManojjena
Hi Rajesh,
You can, however  why you need to call finish method as it will automatically call when your execution is over .
You have to create a instance of your class .
Instance of Database.BatchableContext .While calling the method you need to pass the instance of Batachable context .
Eg-BatchClass bcls=new BatchClass();
Database.BatchableContext  bc;
bcls.finish(bc);
Your method will execute but in which scenario you need to call this ?

 
Rajesh AnnamRajesh Annam
@Manoj,
             Thanks for the reply, I am newbie here while going through the documents I got this doubt. as per my knowledge a method can be called by creating instance. but this is a batch process where all methods executed automatically.Now its clear on this topic.