You need to sign in to do that
Don't have an account?
pooja biswas
System.CalloutException: You have uncommitted work pending in soap api
Hi friends
I have just started working on soap api.
I have 2 salesforce accounts i.e flipkart(source) and hdfc(destination).
The requirement is when an account record is created in flipkart, the same account name will get created in HDFC along with a new contact which will be associated with new account.
I have generated & uploaded the wsdl fiels respectively and set the respective end points.
The issue is when I call the code from anonymous block in flipkart side it throws "System.CalloutException: You have uncommitted work pending" exception, I read the documentation but I am afraid I do not have any knowledge on how to go about it.
Please help me out.
Code In HDFC account:
Thanks
Pooja biswas
I have just started working on soap api.
I have 2 salesforce accounts i.e flipkart(source) and hdfc(destination).
The requirement is when an account record is created in flipkart, the same account name will get created in HDFC along with a new contact which will be associated with new account.
I have generated & uploaded the wsdl fiels respectively and set the respective end points.
The issue is when I call the code from anonymous block in flipkart side it throws "System.CalloutException: You have uncommitted work pending" exception, I read the documentation but I am afraid I do not have any knowledge on how to go about it.
Please help me out.
Code In HDFC account:
global class SoapDemo1 { webservice static void CreateContact(String accName,ID accountID) { Account a=new Account(); a.Name=accName; Database.Insert(a); //create contact Contact con=new Contact(); con.LastName='LName1'; con.AccountID=accountID; con.Account.Name=accName; Database.Insert(con); } }Code in flipkart account: (Below code is written in anonymous block)
Account acc=new Account(); acc.Name='SoapDemo1'; insert(acc); P2.soap part = new p2.soap(); p2.LoginResult lr = part.login('hdfcBank@sfdc.com','ecom2B07O2OcHcXhN4kLd83M5eiAulN4'); Generated_From_WSDL.SoapDemo1 obj1 = new Generated_From_WSDL.SoapDemo1(); obj1.sessionHeader = new Generated_From_WSDL.SessionHeader_element(); obj1.sessionHeader.sessionId = lr.SessionId; obj1.CreateContact(acc.Name,acc.ID);well, I hope I am clear.
Thanks
Pooja biswas
You cannot make any DML before Callout, need to remove below code. Adjust your logic.
Hope this will help you!