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
Dave The RaveDave The Rave 

View List of fields and their formulas

All,

On one custom object, I have about 50 fields with formulas (I did not create them). I would like to list these fields and their formulas in a tabular way.

Does anyone know I can get this detail out of Salesforce and paste nicely in to Word/Excel?
Alain CabonAlain Cabon
Hi, 

This is a short code when you don't want to install a free application from apexchange:  https://appexchange.salesforce.com/
  1. Copy/paste the code below in the anonymous window (CTRL+E) of the Developer Console
  2. Replace the value of myObjectId and execute it.
  3. Download the Log result (raw log if you prefer, right click in tab Log) and filter it in any text editor for the lines with USER_DEBUG 
 
String myObjectId = '01I0Y000000Wosl';
        String retVal = '';		
        //Pull custom field rows
        String response = getHTTP('/services/data/v42.0/tooling/query/?q=SELECT+DeveloperName+FROM+CustomField+WHERE+TableEnumOrId=\'' + myObjectId + '\'');
        
        //Pull URL for each custom field
		Map<String, Object> resultMap = (Map<String, Object>) JSON.deserializeUntyped(response);
        List<Object> records = (List<Object>) resultMap.get('records');
                
        for (Integer i = 0; i < records.size(); i++) {
            Map<String, Object> row = (Map<String, Object>) records[i];
            
            string fieldName = (string) row.get('DeveloperName');
            
        	Map<String, Object> attributeMap = (Map<String, Object>) row.get('attributes');    
            
            //Pull metadata for each custom field
            String customFieldResponse = getHTTP((string) attributeMap.get('url'));

            pattern formulaPattern = pattern.compile('(?i).*"formula":"(.*)","formulaTreatBlanksAs".*');
            matcher formulaMatcher = formulaPattern.matcher(customFieldResponse);
           
            if(formulaMatcher.matches()) {
               retVal = '|' + fieldName + '|' + formulaMatcher.group(1).replace('\\r','').replace('\\n',' ').replace('\\','');
               system.debug(retVal);
            }
        }
    
   //Submit an HTTP GET request
    static public String getHTTP(String svcURL) {
        //HTTP objects
        HttpRequest req = new HttpRequest();
        req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
        req.setHeader('Content-Type', 'application/json');
        
        String domainUrl = URL.getSalesforceBaseUrl().toExternalForm();       
        req.setEndpoint(domainUrl + svcURL);
        req.setMethod('GET');                
        Http h = new Http();
        HttpResponse res = h.send(req);	
        return res.getBody();
    }
This code is short but quite powerful because you have access to all the metadata values of the fields.

https://github.com/regularcoder/deepfield/blob/master/classes/DeepFieldController.cls
At the first execution, you will get the following error if you don't define an authorized endpoint (very easy).

 Please check: Setup->Security->Remote site settings. 

 Use this endpoint = https://your-org-domain.salesforce.com/services/data/v42.0/tooling/query/  (after the save, it is simplified)

User-added image

 
Alain CabonAlain Cabon

2) Replace the value of myObjectId with an Id of a custom object or the name of a standard object (Account, Contact, Opportunity, ...).
and execute it.


String myObjectId = '01I0Y000000Wosl'; // for MyObject__c

or

String myObjectId = 'Account'; 
 
Alain CabonAlain Cabon

FieldPro (free): https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3A00000EcsCZUAZ

Lightweight one-page application which enables Salesforce users to search/report/run-impact-analysis/find-metadata-references in all fields with lightning speed.
Alain CabonAlain Cabon
The first following tool Field Dumper is just what you need probably (install it for the administrators only).

These free tools are often excellent (easy to install and use).

Field Dumper - Extract Data Model to Excel:  https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3A00000EJg2hUAD
Produce an Excel document that lists out your data model - showing field level information for your Salesforce objects. Supports extract of multiple custom and standard objects to a single workbook.

Metadata Search:  https://appexchange.salesforce.com/appxListingDetail?listingId=a0N30000009wgF7EAI
Quick search Setup Audit Trials, Approval Processes, Business Processes, Workflows, Validations, Fields, Objects, Reports, Dashboards, Custom Settings, Apps, Roles, Profiles, Groups, Queues, Sites, RecordTypes, Links, Classes, Triggers, Pages etc.

Octopushttps://appexchange.salesforce.com/appxListingDetail?listingId=a0N3000000B5cEKEAZ
Octopus allows you to document all the items in your Salesforce instance. Get information about apex classes, pages, workflows, triggers, objects, fields and much more in a single place. You can also download it as a PDF/Word file for future reference.

Schema Surfer: https://appexchange.salesforce.com/appxListingDetail?listingId=a0N30000009wZM3EAM
Schema Surfer is the fastest way to browse and explore object metadata inside salesforce.com.

Great New Zealand tools for admin online (Heroku, no installation needed ): Toolkit for Salesforce: https://cloudtoolkit.co/
Welcome to the Toolkit for Salesforce! The tools and applications below provide assistance for common consulting processes and tasks - from diagnosing your org, comparing environments to activating and deactivating Salesforce components.

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. None of your organisation information or data is captured or kept from running this tool.
https://schemalister.herokuapp.com/
Alain CabonAlain Cabon
Great New Zealand tools for admin online (Heroku, no installation needed ): Toolkit for Salesforcehttps://cloudtoolkit.co/
Welcome to the Toolkit for Salesforce! The tools and applications below provide assistance for common consulting processes and tasks - from diagnosing your org, comparing environments to activating and deactivating Salesforce components.

Salesforce Schema Lister:  This tool uses the Salesforce Metadata API to build a list of objects, fields and field attributesfrom within your Salesforce Org. None of your organisation information or data is captured or kept from running this tool.
https://schemalister.herokuapp.com/

User-added image

User-added image

Toolkit for Salesforce is interesting because you don't need to install the tool on any of your orgs including the production org.

My "TestAll" object uses many big formulas and that works fine.

Exported XLSX with Open Office (free):

User-added image