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
abhishek satputeabhishek satpute 

there is some sort of code and that code we have to call in batch then how you call and where we should write that code ?that is important and i want to call it again and again for execution

there is some sort of code and that code we have to call in batch then how you call and where we should write that code ?that is important and i want to call it again and again for execution
AnudeepAnudeep (Salesforce Developers) 
Hi Abhishek, 

You should look at calling another apex method from another class. In your execute method just simply call your other apex method, passing the batch list of records as a parameter:

Batch
 
// some code ...

global void execute(Database.BatchableContext BC, List<sObject> scope)
{
    // if public/global and not static
    YourOtherClass instance = new YourOtherClass();
    instance.myMethod((List <Case>)scope);

    // if static
    // YourOtherClass.myMethod((List <Case>)scope);
}

// some code ...

And your other class' method should look like this:
 
public static void(List <Case> cases)
{
    // do something with the cases
}

Let me know if this helps, if it does, please mark this answer as best so that others facing the same issue will find this information useful. Thank you
abhishek satputeabhishek satpute
How to call if other method is static. You commented above ,I don't get that about hoe call static method