Orphaned records in Widgets database table

When an Entity Screen is deleted, SambaPOS neglects to delete the related widgets (Widgets with EntityScreenId matching the Id of the deleted Entity Screen).

I often Clone a screen as a quick backup before making changes (also append -backup or whatever to it’s name). Then delete the backup later when I’m totally happy with the changes.

The Entity Screen cloning creates a bunch of cloned Widgets but those are not deleted when deleting the screen, so i ended with hundreds of orphaned widgets in the database!

No much harm done … but it clogs memory and could harm performance.
In my case a custom Widget Management system was showing all those dead widgets with Duplicate widgets names and that was a real problem.

You can run a simple SQL script to clean up that mess:

DELETE FROM Widgets WHERE EntityScreenId NOT IN (SELECT Id FROM EntityScreens)

I have that stored as a Database Task.

1 Like