• Greg A Shaw
  • NEWBIE
  • 0 Points
  • Member since 2015


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hello. Currently when we approve Opportunities an Apex trigger creates custom Invoice objects with status = "Pending".

A trigger on this custom Invoice object checks for that status and if found makes a call to a future method (prefaced with "@future(callout=true)")  in another Apex class with the set of new Invoice objects.  This method then makes a callout to our external invoicing service for each of the new invoices.

The problem occurs at the start of each month when we approve approximately 50 new Opportunities. An exception is thrown at the point that the call to the external invoicing service: You have uncommitted work pending. Please commit or rollback before calling out.

My question is: why is this exception being raised when the callout is done within a method marked as @future?

Kind regards, Bill