7

I want to know class is dependent to which class, object, and Field.

I have tried to retrieve data from SymbolTable but it doesn't show me dependent Class Name or ID.

Is there any another way to know dependency of class programatically.

5
  • You should look at this post: Trying to get SymbolTable of an Apex class and get null. It would be much better if you provide a code sample also with some info of issues you faced.
    – Mr.Frodo
    Commented Jun 3, 2016 at 7:16
  • Thanks for quick reply Mr.Frodo, I have already tried your mention link but it dosen't shows dependent class ID or Name in Symboltable
    – Mehul
    Commented Jun 3, 2016 at 7:28
  • Look into this salesforce.stackexchange.com/questions/60887/…
    – MIX DML
    Commented Jun 3, 2016 at 8:24
  • @Prabhat Kumar : Link you provided is not helpfull.
    – Mehul
    Commented Jun 3, 2016 at 8:47
  • 1
    I would pull the entire project in an IDE and then just search entire solution with a class/field whatever name. At least this would work. Commented Jun 3, 2016 at 9:10

1 Answer 1

4

Update for Summer '18.

There is currently the MetadataComponentDependency queries pilot.

This gives you MetadataComponentDependency 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/unoffical 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.

enter image description here

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 externalReferences for every class, and then work backwards 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 youself.


There is also the mythical ApexClassIdentifier and ApexClassIdentifierRelationship 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.

2
  • 1
    Daniel -- There is an unofficial why to do this ... in line 1; typo but possibly your intent.
    – cropredy
    Commented Jun 4, 2016 at 21:02
  • @Daniel - Thanks For reply, Can you please help me out to find dependent field used in Process Builder, workflow.
    – Mehul
    Commented Jun 6, 2016 at 7:01

You must log in to answer this question.

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