When deleting, changing the API Name, or determining the purpose of a field, it can be necessary to find all the places that field is referenced. Most developers know how to find field references in code using their favorite IDE, but both developers and administrators benefit from being able to find field references in configuration such as validation rules and email templates as well.
Admins: Why Use the Force.com IDE
The Force.com IDE may not seem like a tool made for admins, but it can save a lot of time performing certain tasks that Admins regularly engage in. Perhaps there are a number of workflow rules and validation rules built around a particular checkbox field. In order to get an idea of what that checkbox field does, you could use the Force.com IDE to search for all the validation rules, worflow rules, etc. that reference that field and then look them up in Salesforce to get an idea of what the field is used for. It’s more or less impossible to find every place a field is referenced by pouring through your configuration in the setup menu.
Developers: Why Use the Force.com IDE
A lot of config can be downloaded to your favorite IDE by updating the package.xml file of your Salesforce project with the appropriate Metadata types; however, a number of Metadata types (like ValidationRule and EmailTemplate) do not allow you to use wildcards when including them in your package.xml. This means that you have to explicitly name every Validation Rule or Email Template that you wish to download, which is prohibitively time consuming. When you use the Force.com IDE you can automatically download all Metadata exposed to the Metadata API regardless of whether or not the individual Metadata types allow the use of wildcards in your package.xml.
- Install the com IDE.
- You will need to install the appropriate version of Java and Eclipse first, as listed in the installation instructions linked above.
- Launch the Eclipse and select a directory to use as your workspace.
- This will be a folder under which all Salesforce configuration and code will be saved
- Select File > New > Force.com project and enter.
- A Project Name: the name of the folder that represents this Salesforce instance in your workspace folder.
- Username/Password/Security Token: Must belong to a user with the System Administrator Profile or an equivalent Profile. The “Author Apex” checkbox must also be checked on that person’s User record.
- Environment: this defaults to Sandbox. Change it to Production or Custom Domain depending on what type of Salesforce Org you’re using.
- After clicking Next click the radio box next to Selected metadata components and then click the Choose… button
- Click Select All on the next page and then click OK
- You may have to wait a few minutes for the IDE to load after you click Select All
- Click Finish and wait for your Project to load
Searching for Field References in Code and Config
- In the Package Explorer section on the left side of the page, click on [Name of your Project] > Src > [Any yellow folder under source] > [Any file under that folder]
- Click on the file which was opened in the center of your screen and type CTRL+H
- Enter the API Name of the field you want to search for in the Containing text section and select the Enclosing Projects radio box, then click Search
- When the search is done loading, look at the results at the bottom of the page and look them up in Salesforce
About the Author
Brock has been a Developer and Technical Architect at Silverline since June of 2013. He is a Force.com Certified Platform App Builder and Administrator; and keeps up to date with the latest Salesforce platform updates and development tools.