12

When I have a class I believe I no longer use, I usually attempt to delete it and see if there is an error. This strikes me as one of those things that just must be wrong...but I don't see another way. Can someone tell me what I must obviously be missing? :(

3 Answers 3

4

sure. in eclipse, do a search (Ctrl- H) for the class name. as long as you down loaded, visualforce pages, apex classes, triggers, and sControles that should cover the majority (if not all) cases.

2
  • A similar approach works for VScode. One note of warning: apex can now be invoked by Process Builder / Flow. This means that, unless you've pulled all the flows into your IDE project, you may overlook the usage. When in doubt, create a fresh sandbox and click "delete" on the class. The org will usually stop you with specific flow messages.
    – JimG
    Apr 28, 2020 at 14:33
  • You can also do this in a SOSL query by using: FIND {TheClassYouAreLookingFor} IN ALL FIELDS RETURNING ApexClass(Body, Name) Dec 14, 2022 at 23:23
21

Developer Console shows referenced by in addition to dependencies.

Eg, selecting the BlobController class here reveals that BlobPage uses it as a controller.

references

3
  • Does Developer Console show ALL possible references? Apr 13, 2016 at 13:07
  • @BradThomas not all component types create these bindings Apr 13, 2016 at 15:20
  • Ok. thank you! So how would I be sure that deletion of any class is "safe" in the sense that it should not break anything? Apr 13, 2016 at 17:45
0

The product "Sonar" will tell you which design element(s) reference other design elements, including Apex classes. But whether the class' methods have run lately is not possible afaik.

One could add a "breadcrumb" custom object, and create a breadcrumb record in each class' constructor method, but even that would only show that the class hasn't been used for a time, not that it is unused altogether. For instance, maybe it would be executed in a scheduled job that runs annually. 

You must log in to answer this question.

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