I got code that use getContent() to generate PDF file.It works fine until Summer Release 15 is activated it give me this exception:

|System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out

This is the code

update myObject;    
Blob bPlan = pdfPlan.getContent();

I think it is due to to update myObject before getContent();But before this it works but now it is no longer work.I believe whatever limitation that apply on call out will apply to these two methods.

PageReference getContent() and getContentAsPDF() Methods Behave as Callouts in the Summer Release 15

Any idea how to solve this?

  • 1
    Can you provide the rest of your code? Normally, the solution is to postpone any DML update/insert operations until after the callout. If that's possible for you, I think that would be the solution – Aidan May 22 '15 at 10:42
  • As Aidan mentionned above, you should either postpone the update or you could do it in a @future method if you do not have to wait for a response. – Kevan Feb 21 '17 at 17:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.