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
rikhilrikhil 

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

hi all,

am making webservice callout through batch apex and its working fine with the response am doing dml operations also. but the problem is it only working with scope parameter 1 when given database.executebatch(batchinstance,10) its not working means its updating only one record when ichecked in debug logs  i found this error "System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out"  

 

is any one gone into similar situations?

 

thanks

Avidev9Avidev9

Here is the trick.

You have to make all the callouts before doing any DML.

 

So

This is Allowed : Callout --> DML 

Not Allowed : DML --> Callout

Not Allowed : Callout --> DML ----> Callout