How to make button to undo last saved transaction

How to make button to undo last saved transaction in a grid or a form?

I would approach it this way. When they select the record to be edited to grab all the editable data items and set them as session variables.
Then after the record is updated, grab them all again and compare. Any changes get saved to an update_tracker table with record id, field_name, old var,new var, userid, timestamp.
Then you can have an UNDO button appear that, when clicked, reverses the new var and old var in the table for that record id.
Also a good way to track who changed what so they don’t blame the DB admin :slight_smile:

1 Like

Thanks for response.
But How I can do it, Is there an example or code to make it.

One option is to setup an audit trail, and use that to revert back changes. Another option is to use a shadow table for all the changes but that’s quite some work as you have to intercept all database events and to select the data from the old table and insert it into the history table. Latest option is to add a sequence field and only allow to add new records increasing the sequence. Then you can revert back to the old situation by deleting the last record. Of course there are all kinds of variants to these alternatives.

1 Like

Taking the time to help me was a very nice thing for you to do. Thanks so much. :slightly_smiling_face: