How to setting soft delete all table?
When delete data in table, data is update column deleteAt to timestamp but not delete data, and not show data in list page.
How to setting soft delete all table?
When delete data in table, data is update column deleteAt to timestamp but not delete data, and not show data in list page.
You may replace return true;
line in Row_Deleting server event by return false;
and before that line, you may call ExecuteStatement()
with your UPDATE SQL statement, and update the deleteAt
field with CurrentDateTime()
.
In addition, if your database supports transaction, you need to commit the changes after calling ExecuteStatement()
:
Conn()->commit();
I have used a different approach by adding an "Activated" field to each record in the tables. I do not generate delete options but use edit to turn on/off the activated "switch". All lookups for new data entry only selects active records, but reports show use active and inactive records. I then create a new view to allow the "real" delete and it is protected by the security functions so only the administrator level can access. I have also planned so additional checks before the delete is done - for example is the record linked to another by lookup or similar ?
Hope that is useful,
Dave