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
softcloud2009softcloud2009 

VisualForce Error

When I submit / save the request into my custom object, I receive this error below: 

 
=================================================================

Visualforce Error


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

Class.ProductExt.ProductExtSoap.GetProductLicense: line 62, column 13 Class.ProductExtensionController.getProductDetail: line 89, column 22 External entry point

================================================================= 

 

What is that error means and what am i missing?

 

Thanks.

 

<script type="text/javascript"></script>
skodisanaskodisana

Hi,

 

This error will come Without completing the first request i.e GetProductLicense method ,You trying to call second method i.e getProductDetail. This error mainly will come when you send request to the WebService. 

 

Thanks,

Kodisana

 

softcloud2009softcloud2009

This error will come Without completing the first request i.e GetProductLicense method ,You trying to call second method i.e getProductDetail. This error mainly will come when you send request to the WebService.  


Hi Kodisana,

 

Thanks for your response. How to complete the request? Should I check if the first request complete, then execute the second one?

Yes, I am calling web service to the product details.

 

Thanks.

Imran MohammedImran Mohammed

You cannot perform a DML operation prior to a callout.

All the DML operations should be invoked only after you are done with callouts.

So, make a webservice callout first and then save the request.

 

If you are making multiple callouts, then save all the requests in a list or map and post callouts you save them.

softcloud2009softcloud2009

Hi Imran,

 

Actually, i do an insert after all of my web service callout. So here is the process flow in my code:

 

1. User enter a serial number in the textbox and when click on 'Go' button it will show all of the licenses associated with the serialnumber. This is when I do a webservice call

2. User select the license(s) which they would like to extend.

3. Click save and i will save all of the selected license into an object in salesforce. 

--> in this step when I received the error.

 

Could you please let me know where i am missing?