Delete 1000 TEIs in a certain org. unit at once

Hello guys,
So I have registered like say 1000 persons as TEIs in a certain org. unit and I want to delete them all once. How is that possible? deleting one by one is tiresome

1 Like

Hi @Eris_Vinn,
May I ask how did you get to register all 1000 persons in this Org Unit? Manually? I’m thinking of the following ways but I’ve not tried anyone of these:

  1. Using the Import/Export app, export all the TEIs and then import them again but choosing ‘DeleteRemove values included in uploaded file’
  2. Using an API script to delete the TEIs (or to transfer TEIs to different Org Units?)
  3. If you have access to the database using a script to delete Using an API script to delete the TEIs(or to transfer TEIs to different Org Units?)

When importing, do i populate my TEIs in a template generated from the system or i can use any excel template?

@Eris_Vinn,
Please use the Import/Export app by first exporting the JSON file with the list of all the TEIs that you want to delete from this org unit and then importing it with the delete option.

@Eris_Vinn I tested again on play and it’s working fine, you can test this process there as well before you start. Feel free to post back to the community if anything comes up!

Thanks!

@Gassim Thanks for this solution. However, when I try it, for some reason it will only delete 50 TEI at a time. Do you know how I can make it delete all TEI in a given org unit at once? I’m on v2.37.7.1
Thanks

@Jermacias

Could you check if the export file is limited only to 50TEIs? If so then this is probably a bug, would you create a jira bug issue with steps to reproduce?

Thank you!

@Gassim what is the best way to check that on a JSON file?

1 Like

Hey,
Open the file in the browser or the editor and search for the word ‘trackedEntityType.’ It should show the number of TEIs.

Ok, looks like it is just exporting 50.

Yes but it’s supposed to export ALL, right? Then I think this is a bug… Would you like to create a jira bug issue in jira.dhis2.org?

I will make sure to follow up on this and please share the link here so other will get to watch/vote. Thanks!

Here is the link to the jira bug issue: [DHIS2-13670] - Jira
Not sure if I provided enough info, let me know. Thanks

1 Like

Okay, thanks! I added some details like steps to reproduce.

1 Like

Hi @Jermacias and @Gassim

I am experiencing this exact issue on my DHIS2 instance version 2.37.9. only 50 TEI are exported. Please has this issue been resolved please advise.

Hi @Mr_jorge

Thank you for the post. This is still reproducible in the latest version of DHIS2 so I will follow up again with the software team. :+1:

1 Like