I need to write a trigger in which callout is made to external system.If there is any exception i.e 5XX then the next request should be made after 5min from the same trigger and after 5 iteration I need to send a mailer.

closed as off-topic by Eric, Ratan Paul, Adrian Larson, Adam Spriggs, Vigneshwaran G Sep 19 '16 at 14:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on problems in code you've written must describe the specific problem and include valid code to reproduce it. For help writing short, self-contained syntactically-valid examples, see: SSCCE.org" – Eric, Ratan Paul, Adrian Larson, Adam Spriggs, Vigneshwaran G
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    One possibility is an async framework such as the one in Dan Appleman's 3rd Edition Advanced Apex chapter 7 that has a provision for scheduling async events – cropredy Sep 19 '16 at 5:40

You have 2 options:

  1. use a future method, is a method that run async. here it is the documentation
  2. Mark a record with a flag('I use to use a checkbox') and have secheduled class to process the marked records (I use to use a batch class).Here doc of batch And Here doc of scheduled class

Here you have the doc of async process. It explain when you should use all the async types.


You can schedule an apex class that does that work for you:


Not the answer you're looking for? Browse other questions tagged or ask your own question.