0
votes

I am new to Salesforce and trying to figure out a way to determine all the components such as ApexPages, ApexClasses, Triggers etc. in which a custom field is referenced.

Is there any API available for this ? Can metadata API fetch such references of a custom field/object in all components ?

1

1 Answers

1
votes

There isn't an elegant way of doing this.

If you have a sandbox, you can attempt to delete the field. If it's referenced in other parts of your org, it will usually not allow you to delete the field and I believe it also gives you a link to where it is referenced. This isn't a complete solution, however, because if you have a field referenced in Javascipt in a VF page or as a field in a dynamic SOQL query (ie. Database.query('Select Id, Custom_Field__c from Account'), Salesforce won't be able to detect that the field is referenced.

A more complete solution requires more effort. I suggest using the Eclipse Plugin or the Ant Migration Tool to download all of your items (Pages, Classes, Triggers) locally. Then you can perform a simple search/find across the text files to find reference to your file.

Finally, a newer option that is probably even easier is to use the Developer Console. It has recently gained the ability to 'Search in Files.' You can open it from inside Developer Console under the 'File' menu option.