Is it possible to bulk insert data, that will fire an after trigger, that calls to a web service, and have the web service bulk update each of the records?

I know I am running into a number of issues here with DML and webservices being called one after another. Could I possibly have the trigger fire, call batchable apex, call the webservice/update in the execute block?

Or do bulk updates/webservice calls and triggers not mesh?

  • 1
    A lot of the "how or what to do" will depend on the requirements and capabilities of the webservice you are communicating with.
    – Eric
    Nov 21, 2017 at 20:50
  • is the webservice you using bulkified? Can you go with outbound messages instead? Nov 21, 2017 at 21:03
  • @PranayJaiswal unfortunately, the webservice is not bulkified, majority of the time it will be a single use call but every so often we will need it to handle a bulk call. But now that you mention this, I brought it up to my .net developer who wrote the webservice and he is thinking of changing his service to handle bulk...if this happens, I believe all I would need to do it have my code save the records into a list and call his service once with the list as a parameter.
    – Olivia
    Nov 21, 2017 at 21:46
  • @PranayJaiswal after I bulkified my code and my .net developer updated his webservice to accept bulk records, I am still getting the error: FATAL_ERROR|System.AsyncException: Future method cannot be called from a future or batch method: ConsoleApplicationLinkController.getShortenedLinkBULK(String, List<String>, List<String>) Is it not possible? It has to be an after trigger, that calls an apex class, that calls a future method, that has DML in it. Would outbound messages be better?
    – Olivia
    Nov 22, 2017 at 16:27
  • @Olivia - You will need to check system.isFuture and if true NOT call the future method. SO basically, trigger calls future, future makes callout, update records and since checking if context is future in trigger the future will not be called again
    – Eric
    Nov 24, 2017 at 18:43

1 Answer 1


It is possible for the DML statement in the future method to recursively fire the trigger again causing above issue. Use system.isFuture() to skip the trigger logic if it is invoked by future method - if you do not expect any future methods to be updating the object. Else you can use static variables flags - Set them in the future methods and use them to skip the recursive future method callout in the trigger.

You must log in to answer this question.

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