Skip to main content

Code reviews rule: Excessive number of custom fields

Written by David Martin
Updated this week

Excessive number of custom fields

Why is this an issue?

Objects with too many custom fields may indicate:

  • Poor data model design: Data that should be in related objects is denormalized

  • Technical debt: Fields accumulated over time without cleanup

  • Approaching limits: Salesforce enforces a maximum number of custom fields per object

Excessive fields make objects harder to understand and maintain.

Examples

Example of incorrect design (too many fields):

<CustomObject>
<fullName>Account__c</fullName>
<fields>
<fullName>Field_001__c</fullName>
</fields>
<fields>
<fullName>Field_002__c</fullName>
</fields>
<!-- ... 200+ fields on one object -->
<fields>
<fullName>Field_250__c</fullName>
</fields>
</CustomObject>

Example of correct design (normalized):

<!-- Main object with core fields -->
<CustomObject>
<fullName>Account__c</fullName>
<!-- 30-40 core fields -->
</CustomObject>

<!-- Related object for address data -->
<CustomObject>
<fullName>Account_Address__c</fullName>
<!-- Address-specific fields -->
</CustomObject>

<!-- Related object for financial data -->
<CustomObject>
<fullName>Account_Financial__c</fullName>
<!-- Financial-specific fields -->
</CustomObject>

How can I fix violations?

  1. Review field usage: Identify fields that are rarely used or redundant.

  2. Normalize data: Move related fields to child objects.

  3. Delete unused fields: Remove fields that are no longer needed.

  4. Use custom metadata: For configuration data, use custom metadata types instead of fields.

When should I disable this rule?

You may dismiss specific violations for objects that legitimately require many fields, such as complex product configurations.

Resources

Did this answer your question?