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

Can we call Batch apex class on custom button click.

Can we call batch apex class which implements Database.Batchable. on button click(custom button) or visual force tab?



yes we can do that by executing a JavaScript to call a Global class that will inturn run your Batch apex class.


Can u give me the sample code blocks..

global class FinalizeTempLNK {
  WebService static void ExecuteFinalizeTemp(
sforce.apex.execute("FinalizeTempLNK ","ExecuteFinalizeTemp",{ });


    String query = 'Select Id,isTemp__c from Cheque__c' ;
      Finalize_Temp batchApex = new Finalize_Temp (query );
        ID batchprocessid = Database.executeBatch(batchApex);

 Above is the globall class to call the batch apex class.