• rikhilsuhas9
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies

hi ,
i made a webservice callout using batch apex and after getting response  i am doing update operation .this is working fine for when i given scope parameter as 1 in the database.executebatch. however when i pass scope parameter  as10 it only updating 1 value and getting exception like "You have uncommitted work pending. Please commit or rollback before calling out..."   . and am doing dml operation after the callout  & based on callout response result only .
I dint get solution on developer community..
please help me in this scenario.
thanks

hi ,
i made a webservice callout using batch apex and after getting response  i am doing update operation .this is working fine for when i given scope parameter as 1 in the database.executebatch. however when i pass scope parameter  as10 it only updating 1 value and getting exception like "You have uncommitted work pending. Please commit or rollback before calling out..."   . and am doing dml operation after the callout  & based on callout response result only .
I dint get solution on developer community..
please help me in this scenario.
thanks

How do i resolve this...This is my code...I am sending an XML to an endpoint n number of times(its in a for loop)...Cant i do that?

public PageReference saveUsers() {
String[] listOfSelectedUsers = getUsers();
String domainId = System.currentPageReference().getParameters().get('ex');
for(String presentVar: listOfSelectedUsers)
{

Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('http://84.40.30.147/cm/spws');
req.setMethod('POST');

TestExtranet__c extranet = [select Extranet_Name__c from TestExtranet__c where id = :domainId];
Lead lead = [select id,firstname,lastname,email from Lead where id = :presentVar];
String requestXML = buildXMLRequest('createUser',extranet.Extranet_Name__c,lead.id,lead.firstname,lead.lastname,lead.email);

req.setBody(requestXML);
HttpResponse res = h.send(req);
XmlStreamReader reader = res.getXmlStreamReader();
boolean errorExists = parseResponseForError(reader);
if(!errorExists)
{
Extranet_User_Mapping__c mapping = new Extranet_User_Mapping__c();
mapping.Extranet_Id__c = domainId;
mapping.Leads__c = presentVar;
insert mapping;
}else
{

}


}
PageReference userConfPage = new PageReference('/apex/userConfirmation?ex='+ System.currentPageReference().getParameters().get('ex'));
return Page.userConfirmation;
}