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
FippyFippy 

How can I find if/where classes are being used?

Hello,

 

having inherited a huge custom code SF installation, I am trying to prune unused code from production. Is there an easy way to determine if or where an Apex class or VF Page is being used?

 

Thanks,

Graeme

 

SabrentSabrent

You can search for the Apex class/page in the IDE, the Search result will show all the matches where the class/page/trigger is referenced. Hope this helps.

FippyFippy

Definitely an option, albeit a painful one. :) I was hoping there would be something in Salesforce itself that could report on usage and even identify unused pages/classes?

hemantgarghemantgarg

You can check the Dependency button on top of apex class/page. That will show the dependency of a particular class.

FippyFippy

I'll look into that, but it looks like it operates backwards from what I want, i.e. it tells me what the current class references, as opposed to "places where THIS is referenced". I can use it, but with the amount of code we have it will take a while.

 

It would be nice if SF gave us both dependency lists. Our own product has a "places where this is used" option, and we know if it's blank, it's not referenced anywhere in our platform.

 

Thanks,

Graeme

 

RickyPHewittRickyPHewitt

I know this is an old thread, but I just had the need to find where a specific method/class was being used. Using the Force.com IDE (eclipse) I was able to search all the apex in my org for a specific class/ method. 

 

  1. Click Search (Ctr + H) from the top menu and click Search in the submenu
  2. Type in the text to search in the Containing Text feild
  3. Set the File name Patterns to '*'
  4. Set Scope to 'Workspace'
  5. Then click Search


This allowed me to search all apex code. I hope this helps.

Shawn LavoieShawn Lavoie
Check out this nice plugin for Eclipse: http://codescan.villagechief.com/eclipse/
Richard Fiekowsky 3Richard Fiekowsky 3
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 posssible 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 job that runs annually.