I want to delete an apex class that is not used anymore but has dependencies with Flows and LWC etc. What would be an ideal way to retire the apex class? Commenting out the lines or deleting the class and test class using Workbench?

Reason for asking this question is because my apex test class is failing due to a validation rule when run all test class is clicked in production. So this is a good opportunity for me to get rid of the apex class that is not used anymore.

1 Answer 1


Before the deployment, you will have to delete all the versions that have references to the class.

On the same deployment or before you will have to remove all references to the class from LWC components and others.

You can use a workbench (or sfdx or any similar tool) to perform this metadata deployment (which could include the destructive change - deleting the class).

Note: you probably already know but this help page explains in more details the deletion of components.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .