Skip to main content

Use Data

 

OutSystems

Cascade Delete Related Records

 

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:

  1. Go to the entity with the foreign key;
  2. In the foreign key, set the Delete Rule property to Delete.

Example

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.

  1. In the PlaceDetail screen, add the Delete button and implement the logic to delete a place;
  2. In the Data tab, go to the Review entity;
  3. 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;
  4. Publish and test.

  • Was this article helpful?