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.
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
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