You can view custom object field limits by going on:

App > Customize > Object > Limits

Is there a way of getting a list of all objects with the current number of used custom fields?

EDIT: I know there are app exchange tools but I cannot use them - I need a soql quer/ report or a SF native tool (no installations or third parties)

  • 2
    You can do it rather clumsily with the Tooling API in the Developer Console: SELECT count(DeveloperName), TableEnumOrId FROM CustomField GROUP BY TableEnumOrId. But it supplies a mix of standard object names and custom object Ids; I hope there's a better solution. – David Reed Jun 19 '18 at 15:53
  • @DavidReed This actually would have been my first thought. As clumsy as it is, I don't think we have a better tool for this. – sfdcfox Jun 19 '18 at 15:56

I'll convert this comment into an answer.

You can obtain this data rather clumsily with the Tooling API in the Developer Console. Enter the following in the Query Editor, and check the "Use Tooling API" box:

SELECT count(DeveloperName), TableEnumOrId FROM CustomField GROUP BY TableEnumOrId ORDER BY count(DeveloperName) DESC 

That'll get you the objects with the highest count of custom fields at the top. Note that it supplies a mix of standard object names and custom object Ids, each one with the count of custom field attached to it. To find the name of a given Custom Object's Id, you can issue another query:

SELECT DeveloperName FROM CustomObject WHERE Id = 'THE_ID'

Or, of course, you can build yourself a translation table with

SELECT Id, DeveloperName FROM CustomObject
  • Hi David - do I need to add the record type name in the 'developer name' - does the query count how many custom fields are being used by each record type? that's the way I understand it but might be wrong -- can you provide an example? thanks – TheAdmin Jun 19 '18 at 19:33
  • @TheAdmin, all fields on an object are available on all record types, barring validation code or rules. Are you thinking of picklist values, which may be filtered by the current record type? – David Reed Jun 19 '18 at 19:36
  • Sorry, I didnt check the tooling API checkbox - all working now and marked it as accepted answer! Thanks again! – TheAdmin Jun 19 '18 at 20:17

If you can run apex:

Integer count = 0;
Map<String, Integer> custFieldsPerObject = new Map<String, Integer>();
map<String, Schema.SObjectType> GlobalMap = Schema.getGlobalDescribe(); 
    for (Schema.SObjectType Obj : GlobalMap.values()) {
        Schema.DescribeSObjectResult ObjDesc = Obj.getDescribe();
        Integer customFieldCount = 0;
        for (SObjectField aField : objDesc.fields.getMap().values()) {
            if (aField.getDescribe().isCustom()) {
        custFieldsPerObject.put(ObjDesc.getName(), customFieldCount);
           count ++;
           system.debug('Object Name: ' + ObjDesc.getName());
System.debug('Custom Object '+ count);
System.debug('Custom fields per Object '+ JSON.serializePretty(custFieldsPerObject));
Integer maxFields = 0;
String maxFieldsObject = '';
for (String objectName : custFieldsPerObject.keySet()) {
    Integer numberOfCustFields = custFieldsPerObject.get(objectName);
    if (numberOfCustFields > maxFields) {
        maxFields = numberOfCustFields;
        maxFieldsObject = objectName;
System.debug('Max Custom fields: ' + maxFields + ' on ' + maxFieldsObject);

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.