How to get all the formula fields in Salesforce?

Apex Code:

  1. Map<String, Schema.SObjectType> globalMap = Schema.getGlobalDescribe();  
  2. for ( String key: globalMap.keySet() ) {  
  3.   
  4.     Map<String, Schema.SObjectField> fieldsMap = globalMap.get( key ).getDescribe().fields.getMap();  
  5.     for ( String fieldKey: fieldsMap.keySet() ) {  
  6.       
  7.         DescribeFieldResult dfr = fieldsMap.get( fieldKey ).getDescribe();  
  8.         if ( dfr.isCalculated() ) {  
  9.           
  10.             System.debug( key + ',' + dfr.getName() + ',' + dfr.getCalculatedFormula() );  
  11.               
  12.         }  
  13.           
  14.     }  
  15.       
  16. }  

1. Set the debug log level to DEBUG for ApexCode and System. Remaining all should be NONE.


2. Execute the above code in Developer Console.

3. Download the log from Developer Console. Check the below link if you are unsure how to download log from Developer Console.

http://www.infallibletechie.com/2018/12/download-log-from-developer-console-in.html

No comments:

Post a Comment