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
du-scodouglasdu-scodouglas 

Database Rollback

Hi,

 

I am working on a VF page that does alot of DB work, but I don't want to "commit" it until the confirm final step of my wizard.

 

How can I call a database rollback if they page is closed or navigated away from etc.

 

Let me know if more details would help.

 

Thanks,

Scott

Darshan FarswanDarshan Farswan

It can be done by setting up a savepoint and then calling the savepoint whenever we want to roll back the changes.

It works as

  Savepoint sp = Database.setSavepoint();

   // your code  
    
   // rollback if you want

 Database.rollback(sp);

I think this will work for your situation.