When an entity is referenced by other entities through a foreign key, deleting a record from the first entity usually requires deleting the records from the other entities that reference the deleted record. For example, deleting an Order requires deleting all its OrderItems.
In OutSystems, to configure a relationship to cascade delete related records:
- Go to the entity with the foreign key;
- In the foreign key, set the Delete Rule property to
In an application to review and rate places, we want to allow deleting a place. However, when it is deleted we must also delete all its reviews.
- In the PlaceDetail screen, add the Delete button and implement the logic to delete a place;
- In the Data tab, go to the Review entity;
- Select the PlaceId foreign key and set the Delete Rule property to
Delete. From now on, when we delete a place, the referenced reviews will also be deleted;
- Publish and test.