Newer Version Available
Tooling API Usage
1public class YourClass {
2 public void updateAccount(Account acc, String value) {
3 acc.yourField__c = value;
4 update(acc);
5 }
6}In the output of a MetadataComponentDependency query, the Apex class is represented as a metadata component (the component doing the referencing, represented by MetadataComponent* field values). The custom field is represented as a referenced metadata component (represented by RefMetadataComponent* field values). Each row in the output shows a directional dependency from one metadata component (such as YourClass) to one of the metadata components that it references (such as yourField).
- Id
- The ID of this component.
- Name
- The name of this component (for example, YourClass).
- Namespace
- The namespace this component belongs to (or, if the component isn’t in a package, null).
- Type
- The type of the component (for example, ApexClass).
- MetadataComponentId: "01p000000000SOMEID"
- MetadataComponentName: "YourClass"
- MetadataComponentNamespace: null
- MetadataComponentType: "ApexClass"
- RefMetadataComponentId: "00N000000000SOMEID"
- RefMetadataComponentName: "yourField"
- RefMetadataComponentNamespace: null
- RefMetadataComponentType: "CustomField"
1public class ClassA {
2 public ClassB newB() {
3 return new ClassB();
4 }
5}1public class ClassB {
2 public ClassA newA() {
3 return new ClassA();
4 }
5}- MetadataComponentId: "01p00000000SOMEIDA"
- MetadataComponentName: "ClassA"
- MetadataComponentNamespace: null
- MetadataComponentType: "ApexClass"
- RefMetadataComponentId: "00N00000000SOMEIDB"
- RefMetadataComponentName: "ClassB"
- RefMetadataComponentNamespace: null
- RefMetadataComponentType: "ApexClass"
- MetadataComponentId: "01p00000000SOMEIDB"
- MetadataComponentName: "ClassB"
- MetadataComponentNamespace: null
- MetadataComponentType: "ApexClass"
- RefMetadataComponentId: "00N00000000SOMEIDA"
- RefMetadataComponentName: "ClassA"
- RefMetadataComponentNamespace: null
- RefMetadataComponentType: "ApexClass"
In all but the simplest orgs, MetadataComponentDependency queries return a huge number of rows. It can be useful to limit the scope of your requests by type, name, or ID, to help isolate dependencies on specific components.
1SELECT MetadataComponentName, MetadataComponentType
2 FROM MetadataComponentDependency
3 WHERE RefMetadataComponentType = 'ApexClass'1SELECT MetadataComponentName, MetadataComponentType
2 FROM MetadataComponentDependency
3 WHERE RefMetadataComponentId = yourFieldId