function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Somasundaram SubramanianSomasundaram Subramanian 

apex class deletion

I need to delete morethan 50 apex classes, each class is referred in either Apex page or some other class, when i delete the class manually in UAT , will it throw error?
if i use workbecnh and delete then will it take care the reference and delete ? please advise
SwethaSwetha (Salesforce Developers) 
HI Somasundaram,

When you delete an Apex class manually in the Salesforce user interface or through a development tool like Workbench, Salesforce will automatically check for references to the class before allowing the deletion.

If there are any references to the class, Salesforce will prevent you from deleting it and display an error message specifying the dependencies.The error message will inform you about the specific references that need to be resolved before you can proceed with the deletion.

​​​​​​To delete multiple Apex classes, you can use Metadata API using tools like  Workbench following the "destructiveChanges.xml" approach as mentioned in

If this information helps, please mark the answer as best. Thank you
Arun Kumar 1141Arun Kumar 1141
Hi Somasundaram,

When you try to delete an Apex class manually in a Salesforce UAT (User Acceptance Testing) environment, Salesforce will prevent the deletion if the class is referenced by other components such as Apex pages, triggers, or other classes. In such cases, Salesforce will display an error message indicating the dependencies that prevent the deletion.

To delete an Apex class and its dependencies successfully, you need to remove all references to the class from other components (e.g., Apex pages, triggers, other classes) before attempting the deletion and once you have removed the dependencies and verified the changes, you can proceed with deleting the Apex class manually in the Salesforce UAT environment or using a metadata deployment tool like Salesforce Workbench.

If this helps you mark it as a best answer,