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
IceEngineIceEngine 

[Field References] How to get Field referenced by List ?

Hi, as everyone knows when to delete a custom field, salesforce check the referenced source, such as Visualforce page, Apex class.
For example, if you want to delete [custom__c] field in an object, a deleteredirect.jsp page will show a list  that [custom__c] field has been referenced by, so that you couldn't delete it.

My problem is, I want to get the Referenced by List of all the fields in my Schema, but to delete all the fields one by one Manually is not a good way.

So is there a good solution?
Any help would be much appreciated!

Best Answer chosen by Admin (Salesforce Developers) 
Cory CowgillCory Cowgill

IceEngine,

 

There is no out-of-the-box solution for what you want to do.

 

However, you can use the Metadata API to create a utility which would do this functionality.

 

The Metadata API allows you to download (almost) all of your Force.com configuration (Object & Fields, Layouts, Visualforce PAges, Apex Triggers, Apex Classes, Workflows, ETC) as  XML files.

 

By using the Metadata API, you could build a tool that downloads your metadata as a set of XML files, does a REGEX or Scan against all the XML files for the Field Names (API Field Names), and generates a list of the referenced Objects, Pages, Apex, ETC.

 

Into to Metadata API

http://wiki.developerforce.com/page/An_Introduction_to_Force.com_Metadata

http://www.salesforce.com/us/developer/docs/api_meta/

 

Sample Application Using Metadata API

http://wiki.developerforce.com/page/Metadata_Mashup_%E2%80%93_Exporting_MySQL_Schemas_to_Force.com

 

Hope that helps

All Answers

Cory CowgillCory Cowgill

IceEngine,

 

There is no out-of-the-box solution for what you want to do.

 

However, you can use the Metadata API to create a utility which would do this functionality.

 

The Metadata API allows you to download (almost) all of your Force.com configuration (Object & Fields, Layouts, Visualforce PAges, Apex Triggers, Apex Classes, Workflows, ETC) as  XML files.

 

By using the Metadata API, you could build a tool that downloads your metadata as a set of XML files, does a REGEX or Scan against all the XML files for the Field Names (API Field Names), and generates a list of the referenced Objects, Pages, Apex, ETC.

 

Into to Metadata API

http://wiki.developerforce.com/page/An_Introduction_to_Force.com_Metadata

http://www.salesforce.com/us/developer/docs/api_meta/

 

Sample Application Using Metadata API

http://wiki.developerforce.com/page/Metadata_Mashup_%E2%80%93_Exporting_MySQL_Schemas_to_Force.com

 

Hope that helps

This was selected as the best answer
Cory CowgillCory Cowgill

Also using the Metadata API you could build a process to update those files too (I.E. En Masse Commeent out the references, save the metadata, delete the fields)

IceEngineIceEngine
Thanks a lot ! Cory Cowgill, I will get to it
Ben EdwardsBen Edwards
Pretty old thread but adding another option. I have a free and open source app that scans the fields in your Org and returns the components it's used in (Workflows, Processes, Page Layouts, Apex etc).

Keep in mind that returning fields in Apex and VF is not 100% accurate, as a field with the same API name on different objects would return as being found in a class, even though it might not (as others have mentioned).

Also, it can take quite a while to run on large Orgs.

App: http://schemalister.herokuapp.com/

Source Code: https://github.com/benedwards44/schemalister
 
FieldPro AdminFieldPro Admin
Try FieldPro (https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3A00000EcsCZUAZ). This lightweight application enables Salesforce users to search/report/run-impact-analysis/find-metadata-references in all fields with lightning speed.