
1 answer
Hi Sakthidasan,A batch apex can be called from a class as well as from trigger code. But, we have to be very very carefull while calling a batch apex from trigger.In your Trigger code something like below :-
My only concern is that the Trigger would fire on the DML events and that would invoke the Batch.Do you want to run batch as many times as the Trigger would fire ?? Then you can proceed, but my personal openion is not to go with it.Please follow the below links on the same post:// BatchClass is the name of batchclass
BatchClass bh = new BatchClass();
Database.executeBacth(bh);
http://sfdcsrini.blogspot.com/2014/06/how-to-execute-batch-apex-using-apex.html
https://developer.salesforce.com/forums/?id=906F0000000AarkIAC
https://developer.salesforce.com/forums/?id=906F00000008zgyIAA
http://salesforce.stackexchange.com/questions/92047/call-schedulable-batch-class-from-trigger-instead-of-any-schedule
http://www.cloudforce4u.com/2013/11/call-batch-apex-from-trigger.html
http://theblogreaders.com/how-to-execute-batch-apex-using-apex-trigger/⌗.Vuo5DOYohv5
http://www.infallibletechie.com/2012/05/how-to-run-batch-apex.html
Batch Apex Best Practiceshttp://sfdcrocket.blogspot.com/2013/12/batch-apex-best-practices.htmlPlease do let me know if it helps you.
Regards,
Mahesh