Page 1 of 1

Soft delete (marked a record as deleted but not delete data)

Posted: Tue Mar 26, 2024 9:54 pm
by totza2010

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.


Re: Soft delete (marked a record as deleted but not delete data)

Posted: Wed Mar 27, 2024 2:52 pm
by arbei

I believe you can only customize the generated script to do that.


Re: Soft delete (marked a record as deleted but not delete data)

Posted: Wed Mar 27, 2024 4:04 pm
by totza2010

Yes, I'm testing customizations. But try asking in case there is anyone who has ever tried this. or can give additional advice.


Re: Soft delete (marked a record as deleted but not delete data)

Posted: Wed Mar 27, 2024 6:09 pm
by mobhar

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();


Re: Soft delete (marked a record as deleted but not delete data)

Posted: Sat Mar 30, 2024 5:15 am
by daveb

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


Re: Soft delete (marked a record as deleted but not delete data)

Posted: Mon Apr 08, 2024 8:30 pm
by vintoICT

Simple add a new column on the table . Name softdelete or any name u want . Make it Int . Set default value to 0 . On deletion update the table where id to 1 .

To hide soft deleted data on list page for example , filter on table setup where softdelete = 1