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
JayaJayaJayaJaya 

Urgent Please : Related to Web Service invocation

Hi,

 

I have a requirement in which I need to call two web services as part of the program flow.

 

1. The first web service call, on success, inserts a new Account and returns the Id

2. The second web service call needs the above newly created AccountId as input parameter.

 

I am getting "Uncommitted Work Pending" exception if I use two web service calls directly in my program because first web services in creating a new Account which is a DML Operation.

 

Please let me know the ways to use the above two web service calls in my program. I tried using @future annotation but it didnt solve my problem. Please let me know any alternative way to use.

Also kindly let me know if JS remoting works for invoking the web service(I will put web service call in a controller method and call it from JS), will it work.

 

Immediate response is highly appreciated as this requirement is urgent. Thanks in advance.

 

 

Thanks,

Jaya.

Avidev9Avidev9

Well the thumb rule here is you have to do all your Callouts before the DML.

So the Sequence should be
Callout 1 ---> Callout 2 ---> DML 1 --- > DML2

You cant have
Callout --> DML ---> Callout

Bhawani SharmaBhawani Sharma
You can not do dml before a callout in a transaction. Follow "Avidev's" instruction.
Raj SFcloudsRaj SFclouds

You can't callouts, HTTP or or else, once you have made changes to the database. You either need to assign the transaction, make the callout previous to any database changes or move your callout to a @future method.