How to delete program stage in tracker

HELLO, I CANT DELETE PROGRAM STAGE IN TRACKER, IT SAYS “Could not delete due to association with another object: TrackedEntityDataValue”

1 Like

Hi @ahly,

We have these checks in place to make sure you don’t delete metadata that is used to describe actual data. Since you have some data referencing your program stage, we stop you from deleting it.

The only way to circumvent this, is to first delete the referencing data, then delete the program stage.

It’s also worth noting that this also happens if you are trying to delete metadata that other metadata is depending on. These are all just checks to make sure you don’t accidentally corrupt your data.

1 Like

Sorry what do you mean by referencing data?

1 Like


the easiest example I can give you is the following:

You have a DataElement “weight” in a Program Stage “birth”. weight and birth is metadata.
When you register a new birth, you create a new event based on “birth” program stage and enter the weight of the baby into the DataElement “weight”. the creation of the event and the value you put into weight are both data.

If you now try to delete the DataElement “weight”, the database would still have information about the value, but not what the value means. so in other words, the value is useless.

The same happens if you delete the program stage. We have a weight, and we know something happened, but not what.

Our check is to avoid this last case, where we have data (the event and the weight) but no metadata to describe what it means.

So when I say “referencing data” I mean in this case the event and the weight, not the program stage or data element :slight_smile:
I hope this clears it up.


Thanks understood::stuck_out_tongue_winking_eye:

1 Like