Root Department cannot be deleted

I want to delete the entry of department in setup module. But it gave me below error

Root Department cannot be deleted

How can i delete the created entry from Setup module?


Facing same issue any update

Are you trying to deleted “All Departments”? Note that this cannot be deleted as this is considered to be the root node of all the departments under it. You can however delete the other depts under “All Departments”. Same applies for all doctypes having tree structure, for example, Customer Group, Supplier Group, etc.

1 Like

This is true the best op can do is rename the root department I guess.
That’s what I used to do when client would argue to change it.
Idk if its still allowed in v12.

This is not allowed currently. Unsure if it was allowed earlier. Currently, this root node cannot be edited or deleted.

This needs to be configurable per doctype. The current design doesn’t even make sense.

If you forcibly prevent deletion of all root records, then it brings up paradoxical questions like:

  • If there is a single root, why not make it implied? Why even include the root in the data model? A single root only has virtual meaning and its practically pointless to model it as data. There’s no need to explicitly prevent deletion of a single root since its implied always – you can’t delete it by nature. Maybe this is why root deletion prevention was added to begin with, however see next point…
  • If there are multiple roots, why prevent deleting them? If you want to create multiple roots, you almost certainly want the ability to delete them.
  • Lastly, why is it ok to prevent multiple root deletion but allow deletion of branches? An argument can be made that deleting branches is just as dangerous as deleting roots! One could argue that you shouldn’t be able to delete anything except for leaf children – but that’s just crazy!

A better design would be a configurable option on the doctype as to whether or not root-level documents can be deleted. Going further: when the user attempts to delete a root level document, instead of automatically blocking or passing, prompt them with a warning about the consequences.

I’ve raised an issue about this: