Wednesday, February 16, 2022

Salesforce: Retrieve all fields from an Object

Config Workbook

This tool is not free, but you can do a trial for a few analyses, and need to install it from AppExchange.The details provided are quite comprehensive, but missing a few important pieces of information.

Click CWB Tool tab >> Reports tab >> Full Object and Fields Details Only.

This will produce an Excel file with the following columns:
  • Field Name
  • API Name
  • Data Type, missing information if the field is a Formula field
  • Picklist Value, for Picklist field only, and not for Multi-Select Picklist  
  • Length, for Text and Long Text Area
  • Visible Lines, for Long Text Area
  • Default Value
  • Mandatory
  • External ID
  • Unique
  • Case Sensitive
  • Description
  • Help Text
  • Relationship, for Lookup: Related To (object name) and Child Relationship Name
  • Number, with Precision and Scale, for the length of Currency, Number, Percent field
  • Track Feed History
  • Track History

It also missing Controlling Field, Modified By, Modified Date/Time information.

ColumnCopy extension for Chrome browser

This needs to be performed in Classic (not Lightning) with Chrome (or Edge or Opera) browser, you just need to add ColumnCopy to your browser. Once the extension is added in your Chrome browser, go to the object's field page, right-click on the field table >> ColumnCopy >> Copy entire table >> paste into Excel.

You will get all information presented in the fields table:

  • Field Label
  • API Name
  • Installed Package
  • Data Type
  • Indexed
  • Controlling Field
  • Modified By (including Modified Date/Time)
  • Track History

* Indexed and Track History will not copy by ColumnCopy because they are checkboxes.

This is good enough if you just need to get basic field information quickly.

Salesforce Schema Lister

This tool uses the Salesforce Metadata API to build a list of objects, fields, and field attributes from within your Salesforce Org, this tool is part of the Toolkit for Salesforce, and please note this is a 3rd party tool, not by Salesforce.

The tool will scan all objects, instead of asking with objects that you would like to work with. This will work well if you are just starting a new org, but when working in a big org. (with hundreds of custom objects), it may take a few minutes or longer.

Once completed, you have the option to export the data into an Excel file, as a single tab or multi-tab (one object per tab).

What do you get in the Excel file?

  • Field Label
  • API Name
  • Type. including length (all fields), picklist values (including multi-select picklist)
  • Help Text
  • Formula, this is the raw formula for the field


Query from FieldDefinition object.

Sample: SELECT DurableId, QualifiedApiName, Label, DataType, ValueTypeId, LastModifiedDate, PublisherId, Length, Precision, Scale, EntityDefinitionId, RelationshipName, ReferenceTo, Description FROM FieldDefinition WHERE EntityDefinition.QualifiedApiName = 'Account' 

You must have EntityDefinitionId or DurableId added as a filter, EntityDefinitionId refers to an object and DurableId for a field.

A few interesting fields from the query result:
  • DurableId, return ObjectName.QualifiedApiName for standard object and ObjectName.00Nxxx for custom fields
  • ValueTypeId, return id, string, boolean, integer, double, etc.
  • PublisherId, return System for standard objects, or Package Prefix name for installed packages

Full documentation here

Note: Because this is a query based on the user permission, the query result will be based on field (and object for lookup field) visibility for the login user. 
You don't option to retrieve Help Text here.

Custom Report Type

Create a custom report type with primary object = Entity Definitions with or without records from Field Definitions.

You can filter Durable ID (of Entity Definitions) to an object name to pull just fields of that object. Sample report:

Note Same as SOQL, the report runs based on the user permission, so the result will be based on field (and object for lookup field) visibility by the report running user.
You don't option to get Help Text using this method.

Salesforce DevTools

This is another Google Chrome browser extension that is mainly focused on Salesforce admin/dev productivity. You can get it and include more information from this site.

From the Salesforce DevTools panel, select the object >> Export >> Object Fields Definition 

You will get an Excel file with the following columns:
  • Field Label
  • API Name
  • Data Type
  • Length
  • Field Type, this is standard or custom field information
  • Required
  • Picklist Values
  • Formula
  • Extend ID
  • Help Text
Note Same as the previous method, the Excel file result will be based on field (and object for lookup field) visibility by the report running user.

So, which methods work best for you? I would say it depends on what you want to achieve, do you need extra information to retrieve, can you install an app into the org., can you switch back to Classic, how complex is the org., do you have visibility to all fields, etc.

No comments:

Post a Comment

Page-level ad