I have a managed app that does a callout (REST API POST) on Account save. The managed app is developed by a 3rd party that we have no control of.

The callout creates a future event which gets an id from the REST API call and saves it in a custom field on the Account object

Now when the id from the REST API is saved to the Account object I want to do another callout to the same REST API to save some more data that the managed app doesn't do.

The problem I am having is because the id that I need from the app callout is set in a future event I can not do another callout because you can not create a future event from with in a future event.

Is there any way around this? Or maybe a different way of solving this problem?

Edit: I'm running out of ideas. I tried executing a batch from my after save trigger and got the following error

System.AsyncException: Database.executeBatch cannot be called from a batch start, batch execute, or future method.

Is the only way around this is to have a scheduled task that runs periodically to do my callout?

  • May be a batch process kick of at regular intervals for your logic ? Jun 25, 2014 at 2:35
  • I'm looking to using the batch system now. Seems like a round about why though
    – Rowan
    Jun 25, 2014 at 3:54
  • 2
    Are you saying that a trigger that responds to the id being set on the Account object (by the initial @future) is not allowed to invoke a @future(callout=true) method? That isn't explicitly excluded in the Future Annotation documentation.
    – Keith C
    Jun 25, 2014 at 7:41
  • @KeithC Seems like the 2nd to last line from the document you linked explicitly says that you can not call a future from a future
    – Rowan
    Jun 25, 2014 at 21:24
  • @Rowan Do you mean "Nor can you call a trigger from an annotated method that calls another annotated method"? Yeah after reading several times you may be right. Personally, before giving up, I'd try it as the documentation can sometimes be misleading and it would be a simple solution.
    – Keith C
    Jun 25, 2014 at 21:45

2 Answers 2


You can use the new Queueable interface in places where you can't use a future method, such as in Database.BatchableContext execute and within future methods. Please note that you're limited to one Queueable call in an asynchronous state (currently), but Queueable jobs can also chain (again, limited for now). This may be sufficient for your use case, however, since your purpose is to effectively chain two callbacks together.


Create custom field Flag on account and when you receive ID from callout set Flag = True.

Then you can schedule another Job that pull all Accounts where flag = True (limit X, x= Limits.getLimitCallouts() ) then get give API call for each account and update them.

While updating make sure you reset the flag.

You will need to consider conflicts depending on the fields you update after callout.

  • This is what I wanted to avoid, I want the callout to happen as soon as possible. I don't want to wait for a schedule to run.
    – Rowan
    Jun 25, 2014 at 21:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .