Friday 8 December 2017

Batch Apex - Email Notification


1. Can we send email notification from Start /Execute methods apart from finish method?


Yes, Its possible.

Ex:Any time if any email needs to be trigger to notify the particular job is started then this can be used.

Ideally most of the business scenario email notification will be triggered from finish method.
Where we will get the final job status.

Sample Test Code From Start & Execute :




2. Can we give the scope value less than default value 200 ?

Yes,It is possible

Ex: Passing the scope as '1' for a Batch class named 'BatchApexUnderstanding'
Database.executeBatch(new BatchApexUnderstanding(),1);

Note : 2000 is max value

3.  Finish method is empty not added any code,And don't want to add any logic,Can we delete the empty function block?
NO,That are inherited from interface and must to implement,Declaration should be there even no logic written in that function block.



No comments:

Post a Comment