You need to sign in to do that
Don't have an account?
Apex Batch Job :You have uncommitted work pending. Please commit or rollback before calling out
Hi All,
I have an Apex Class and have written a Batch Apex and Scheduler Apex Class for it.
When I am trying to run my Batch Job from Developer Console I am getting the below error :
System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out
Since I am a Newbie to Apex Batch Jobs please advise me on how to fix this issue?
Thanks for Any & All Help in Advance...!
I have an Apex Class and have written a Batch Apex and Scheduler Apex Class for it.
When I am trying to run my Batch Job from Developer Console I am getting the below error :
System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out
Since I am a Newbie to Apex Batch Jobs please advise me on how to fix this issue?
Thanks for Any & All Help in Advance...!
Work Around for this..
This workaround splits the transaction into two separate Ajax processes. The first inserts the record and the second performs the callout and is able to update the newly inserted record.
if its not working kinldy use @future Annotation before callout.
Reference from: https://help.salesforce.com/articleView?id=000003701&type=1
https://help.salesforce.com/articleView?id=000079772&language=en_US&type=1
Hope this will solve your issue.
Mark best ASNWER if its works for you.
Thanks
karthik
First you have to abort all schedule job related to your batch job or apex class.then again try to execute your batch.
These are the steps to abort scheduled jobs
if this answer helps you then make it best answer.
I have a single Method which i am calling from my Batch Apex Class->Inside that metthod there are methods which call Webservice callouts.So should i seperate them?
There are no Scheduled Jobs running.
I have commented the Method Calls which uses Webservice Callouts.
Please let me know on how can I seperate it which will avoid the above error. Thanks...!!!
Trying calling this method with Future annotation. Please find below modified code:
Let us know if that helps you.
Best regards,
BALAJI