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.

1 Answer 1

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

1
  • 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 Apr 12, 2016 at 8:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .