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
Jenni at JackJenni at Jack 

Delete Visualforce page & associated Apex class

Hi, I have a VF page & referenced apex class that I need to delete that are no longer used & because of the lack of coverage are preventing me from deploying a trigger & class that I need from my sandbox. I received a Success message when I followed the instructions to delete the apex class from my production org using Force.com IDE however I discovered the apex class is still there since it’s tied to a VF page. Is it safe to delete the VF page & then delete the apex class using IDE once the VF page is gone? Let me know if it’s helpful to post code to answer the question, the apex class was created 3+ years ago by our implementation consultant with 1200+ lines.
Best Answer chosen by Jenni at Jack
Shashikant SharmaShashikant Sharma
I would suggest that first you take the backup of both class and page.

Then go to visualforce page and delete it. If it also have reference somewhere than you need to remove the refrence.

If the reference is in the class making it cyclic referecne then. Remove all code of the VFP and remove the controller="YourClassName"  attribute from the <apex:page tag.

Once you remove code of page you can then delete the Class first and then the VFP.

All Answers

Shashikant SharmaShashikant Sharma
I would suggest that first you take the backup of both class and page.

Then go to visualforce page and delete it. If it also have reference somewhere than you need to remove the refrence.

If the reference is in the class making it cyclic referecne then. Remove all code of the VFP and remove the controller="YourClassName"  attribute from the <apex:page tag.

Once you remove code of page you can then delete the Class first and then the VFP.
This was selected as the best answer
Jenni at JackJenni at Jack
Fantastic, thanks @ShashikantSharma for confirming the steps & for the backup reminder.
Shashikant SharmaShashikant Sharma
Glad that it resolved  the issue :) .
Srija LenkalaSrija Lenkala
Hi , If Vf pages are dependent on vf components then what is the solution