Soft-deletion as out-of-the-box setting of entities - Mendix Forum

Soft-deletion as out-of-the-box setting of entities

3

Many projects get the requirement to apply a soft-delete for at least some entities. This means that instead of removing the record from the database (default hard-delete), a flag is raised to indicate that a record is inactive. This may be a boolean (IsDeleted), but can also be a timestamp (DeletedDate) just like the CreatedDate and ChangedDate. This could enable data restore, but also enables doing analysis like reports on data that got deleted.

Of course, this can be implemented manually by adding this field and update all usages to not retrieve deleted records. Instead, I would suggest to make this an out-of-the-box functionality to enable soft deletion. This makes it very easy to implement, especially when the entity has already a lot of usages. Furthermore, it easier to maintain, as one cannot accidentally add overviews/lists without setting the filter to exclude deleted items.

The delete behavior could enforce that the soft-delete functionality is also set on associated entities: a hard-delete could trigger a soft-delete, but a soft-delete can never trigger a hard-delete.

 

I imagine something like pictured below.

 

The Entity settings get an option to enable soft-delete.

 

If this checkbox is checked, the following options will be available:

 

On a delete action, select if a hard-delete is required; this enables clean-up of soft-deleted items. By default this is set to No.

 

On retrieval, one can select if deleted records should be fetched. By default this is set to No.

 

On overviews, one can select if deleted records should be fetched. By default, soft-deleted items are not retrieved.

 

 

asked
0 answers