You need to sign in to do that
Don't have an account?
You have uncommitted work pending. Please commit or rollback before calling out?
I have class given below
when i call this class method in button ,click i got the follwoing error
{faultcode:'soapenv:Client', faultstring:'System.EmailException: SendEmail failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, You have uncommitted work pending. Please commit or rollback before calling out: []
Class.ItineraryEmail.SendEmail: line 79, column 1', }
the class method is
public string getIB() {
System.debug('Test Flight Request'+listFR);
System.debug('Opportunity'+listOpp);
if(listFR != null && !listFR.isEmpty())
{
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('http://testwebsite/GetCustomerView?opportunityId='+listFR[0].Opportunity__c+'&flightRequestID='+listFR[0].Id);
req.setMethod('GET');
HttpResponse res = h.send(req);
result = res.getBody();
}
else
{
if(listOpp!=null && !listOpp.isEmpty())
{
result = listOpp[0].Confirmation_Email_Content__c;
}
}
return result;
}
please let me know what can i do..
thanks in advace
The comman reason for this error is "you cannot do an insert and then do a callout in the same class" .
All Answers
The comman reason for this error is "you cannot do an insert and then do a callout in the same class" .
Mayank
i know but i m nott insert anything and then do callout that you can see in my code
Hi
i am not getting any proper solution as i created a class with @future method and call this method in main class ..but in button click i got the error
"@future annotion not allowed this time".
thanks