function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
App_Dev1App_Dev1 

You have uncommitted work pending. Please commit or rollback before calling out

I get this error from time to time. It has a bold heading "Pages" with this message:

"
You have uncommitted work pending. Please commit or rollback before calling out"

It happens on a form submit where I'm doing some DML and returning a PageReference. No matter what I do with try / catch I can't seem to trap this error and handle it, say with a rollback or commit as it states.

Any ideas? It's hard to debug this.

jkucerajkucera

For any others that come across this thread - problem is that you cannot do an insert and then do a callout in the same class:

http://community.salesforce.com/t5/Apex-Code-Development/You-have-uncommitted-work-pending-Please-commit-or-rollback/m-p/65825