You need to sign in to do that
Don't have an account?
Karthik Sankar
Callout Exception : You have uncommitted work pending
I am getting this exception "You have uncommitted work pending - Please rollback or commit".
I did the following :
I set a save point ,do an update, Rollback then made a callout.
Savepoint sp = Databse.savepoint();
Update record;
rollback(sp);
makeOutboundCall(X,X,X);
Please help.
SFDC currently doesn't allow you to make callout after your opening transaction. Even though you rollback to the save point, the transaction is still open, so you can't make a callout.
I would say, the message is not appropriate. SFDC even doesn't have commit.
So you have 2 choices.
1. make callout before update.
2. Split the execution. Once you update the record, return to VF page, and continuously call another method to make callout. This is a very tricky thing (I call it "Asynchronous Call Chain"). You may have to check error status in update part before calling callout part. If you don't understand this concept, I don't recommend to take this approach.
<apex:actionFunction name="callout" action="{!callout}"/> <apex:commandButton value="Go" action="{!update}" onComplete="callout();"/> public PageReference update(){ update record; return null; } public PageReference callout(){ makeOutboundCall(X,X,X); return null; }
ThomasTT
Hi,
This is the method in my controller.
public ContactClass GetPersonDetails()
{
// I have write a logic here to fetch the data from web services, and assign this output to the apex page.
}
public PageRefrence save()
{
// this is save method which is call when I click on save button.
// here I am saving the record in salsforce contact page.
// the record is save successfully in contact, but after that it will display an error message that
VF Error
System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out
Class.SalesForcePersonCDNADetail.SalesforceDataSoap.GetAllPersons: line 63, column 1 Class.ContactController.GetPersonDetails: line 28, column 1
}
SF is the new concept for me, It would be appriciable,if any one help on this.
Thanks