You need to sign in to do that
Don't have an account?

one batch apex to another batch apex
we can not call one asynchronous process to another asynchronous process but how can we call from one batch to another batch since batch is also asynchronous process?
Greetings to you!
There's no rule that says that "asynchronous cannot call asynchronous". There are specific rules in place, such as "future cannot call future". A Queueable can call another Queueable, a Batchable can call another Batchable in the finish method, and Scheduleable methods can call Batchable and Queueable methods. There are usually lesser limits allowed for asynchronous contexts (e.g. a Queueable can call only one Queueable, while a normal synchronous transaction can call 50 of them).
Reference: https://salesforce.stackexchange.com/questions/204896/calling-async-from-async-process
To call another batch class from a batch class:
1. Call another batch class in the finish method as execute method is called many times but Start and finish method only once.
2. So once your main batch is completed and the finish method is called and then it will call another batch.
Please refer to the below link which might help you further:
https://www.biswajeetsamal.com/blog/invoke-batch-apex-from-another-batch-apex/
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
All Answers
Greetings to you!
There's no rule that says that "asynchronous cannot call asynchronous". There are specific rules in place, such as "future cannot call future". A Queueable can call another Queueable, a Batchable can call another Batchable in the finish method, and Scheduleable methods can call Batchable and Queueable methods. There are usually lesser limits allowed for asynchronous contexts (e.g. a Queueable can call only one Queueable, while a normal synchronous transaction can call 50 of them).
Reference: https://salesforce.stackexchange.com/questions/204896/calling-async-from-async-process
To call another batch class from a batch class:
1. Call another batch class in the finish method as execute method is called many times but Start and finish method only once.
2. So once your main batch is completed and the finish method is called and then it will call another batch.
Please refer to the below link which might help you further:
https://www.biswajeetsamal.com/blog/invoke-batch-apex-from-another-batch-apex/
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas