Skip to main content
OutSystems

How to clean data from entities

Question

How do I clean the data from my Entities, so that I can start again with good data?

Answer

There are two approaches to delete all data from your entities:

  • Using the Delete Entities action;
  • Perform this through a SQL Query.

To use the Delete  Entity action, you need to:

  1. Get all the records from your database;
  2. Use a For each to iterate over the list;
  3. Delete each record.

The following image shows this approach:

delete data from entitys.png

As a faster alternative, you can create a SQL Query to delete everything from your Entity:

delete data from entitys2.png

Most likely you will reach to a point in time during the project where the users would like to clean test data and start from scratch with good data.

It is a good practice to create a mechanism to delete data for each entity, or for all entities on the eSpace. If you make the action public, users can just reference this action to restart from scratch.

You have to be careful with the relationships between entities. Usually you have to delete first the entities that you have created more recently, because those usually have the relations to "older" entities.

delete data from entitys3.png

  • Was this article helpful?