0

is it possible to implement transaction with php toolkit?

I have to insert data into 2 objects. If there is any problem during the second insert, I would like to rollback the first insert.

0

Consider following limitation on Save point in the context of above question

1) Save point do not work in cross translation. You can not serialize it and use in other context (for ex. other controller action)

2) References to savepoints cannot cross trigger invocations because each trigger invocation is a new trigger context. If you declare a savepoint as a static variable then try to use it across trigger contexts, you will receive a run-time error.

So, Considering above limitation you wont be able to directly use save point from standard SOAP or Rest API.

But there are 2 workarounds for you.

1) Write a custom API which accept both object. In that API first start save point and then update both objects. If required then you can roll it back. Note you may have to design your api to accept bulk of records.

2) Maintain the original copy of those objects and use it when you want to roll it back. By using original copy you can update the object to set it to original state. Note: you will have not be able to system fields and audit history

  • If it helps the you should up-vote the answer. If it solves your problem you should accept the answer. For more details on how to use SFSE please take look at salesforce.stackexchange.com/help – AtulRajguru9 Apr 12 '16 at 8:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.