Getting this error: " This record could not be loaded because it includes too many formula fields with complex formulas, or too many custom fields. Ask your Salesforce administrator to remove some formula fields or simplify the formulas in use."

I am new to Salesforce and came into this org a few years after it was created. I have seen this message before when an admin edited a formula field and I redid their formula to make it cleaner and more efficient to remove this error.

Now that I am getting the message again, I believe I need to review every formula field on the object, but there are 70 formula fields. I would like to find a way I can export all of the formulas for review.

Is there a quick way to do this without going into each field individually?


The Metadata API supports exporting metadata on Custom Fields (CustomField) and you would be able to export all of the field data through that API. This gives you XML on fields and if they contain the <formula> tag then that indicates it is a formula field and the tags contain the formula used on the field. For example:


If you don't have access to a tool that exports data from the Metadata API, then consider using the Developer Workbench. If you click Info > Standard & Custom Objects, then select your object from the dropdown on that page you can then click Expand All to expand all of the field data and then use find (CTRL+F) in your browser for calculatedFormula. This will show you all of the formulas on your object.


I just wrote a sample code to extract formula fields using dynamic apex from org and attach as an excel to a SF record (replace parentId with appropriate record id from your org and replace Object name with your object name). Hope this will help you extract formula fields from your object.

String strFormula = '';
String strTable = '<table><th>Field Name</th><th>Formula</th>';
//replace with appropriate object name  
Map<String, Schema.SObjectField> fieldMap = Schema.SObjectType.Account.fields.getMap();
for(Schema.SObjectField field : fieldMap.values()){
    Schema.DescribeFieldResult dfr = field.getDescribe();
    //isCalculated() is used to identify custom formula fields
    //getCalculatedFormula() != null is used to exclude rollup summary fields as they are treated as formulas
    if(dfr.isCalculated() && dfr.getCalculatedFormula() != null){
        strFormula += '<tr><td>' + dfr.getName() + '</td>' + '<td>' + dfr.getCalculatedFormula() + '</td></tr>';
        //system.debug('Formula Field::' + dfr.getName() + ' Formula::' + dfr.getCalculatedFormula());

strTable += strFormula + '</table>';

Attachment recAttachment = new Attachment();
recAttachment.Name = 'FieldFormulas.xls';
//replace id with any appropriate record id from your org
recAttachment.ParentId = '00190000027ooAe';
recAttachment.contentType = 'application/vnd.ms-excel';
recAttachment.body = Blob.valueOf(strTable);
insert recAttachment;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.