Skip to main content
Added Summer '18 MetadataComponentDependency pilot
Source Link
Daniel Ballinger
  • 103.1k
  • 40
  • 275
  • 601

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.

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.

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.

edited body
Source Link
Daniel Ballinger
  • 103.1k
  • 40
  • 275
  • 601

There is an unofficial whyway 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.

There is an unofficial why 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.

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.

Source Link
Daniel Ballinger
  • 103.1k
  • 40
  • 275
  • 601

There is an unofficial why 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.