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
harisripadmini vharisripadmini v 

fetching dependent class names in apex class, using external references of symbol table

Is there any way to fetch the list of classes being used in an apex class, through external references of symbol table.

Thanks in advance!!
NagendraNagendra (Salesforce Developers) 
Hi Padmini,

Sorry for this issue you are facing.


Update for Summer '18.
There is currently the MetadataComponentDependency queries pilot https://releasenotes.docs.salesforce.com/en-us/summer18/release-notes/rn_metadata_metadatacomponentdependency.htm .

This gives you MetadataComponentDependency https://developer.salesforce.com/docs/atlas.en-us.214.0.api_tooling.meta/api_tooling/tooling_api_objects_metadatacomponentdependency.htm in the Tooling API that you can query for the dependencies. It gives you the details for both the referencing and referenced metadata components.

I've found it useful to take the data from these queries and build it up into a dependency graph.

There is an unofficial way to do this using the same API call that the developer console does.

Disclaimer: Using features from an undocumented/unofficial API means they are subject to change/disappear/break without Salesforce giving you any notification at all. Do so at your own risk
When you select an Apex class in the developer console, it pops up a Related list to the right.

The Chrome developer tools tell us this is populated via a POST to
https://na5.salesforce.com/_ui/common/apex/debug/ApexCSIAPI
With the form data:
action=RELATED&extent=CODE&relatedEntityEnumOrId=01p00000000001AAA

The response will be something like:
while(1); {"success":true,"relatedInstances":{ "relatedInstances":[{"id":"01p70000000LwULAA0","name":"partnerSoapSforceComWebSvcTest","type":"ApexClass","extent":"ApexClass","direction":"Referenced by"}]}, "csiTrace":"Loaded params in 0 millis, user 005700000012rOP\nApexCSIAPI finishing, executed action RELATED in 18 millis"}

Those with the extent "ApexClass" and the direction "Referenced By" will be the ones that depend on the current class.

It is possible to get the data you need with the SymbolTable. However, it is a lot of work. You need to use the external references for every class, and then work backward to resolve those that depend on a given class. It isn't much fun, and it takes a lot of processing as the number of classes increases. You also need to convert the Apex class names and namespaces back to the class ID yourself.

There is also the mythical ApexClassIdentifier and ApexClassIdentifierRelationship http://www.fishofprey.com/2016/03/salesforce-forcecom-ide-superpowers.html API objects. These aren't officially supported and are in a state of flux. Best keep clear of them for anything other than curiosity sake.

For more information please check with below link. Hope this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra