Is there any way to generate XLS/HTML output with below details from Salesforce?

  • List of all STANDARD & CUSTOM Objects
  • Record Counts associated with above objects

Thanks Sri

  • 1
    What is the need for such requirement? workbench and Developer console already has number of options to display that information.
    – Mahmood
    Mar 6, 2019 at 6:21
  • As part of migration from one SF org to other SF org, need this data to identify the Objects & its associated records...as an example, there are many objects that were created for some testing purpose that have ZERO records, would like to ignore those as part of migration... Can you help with options to get these details from workbench, developer console?
    – Sri
    Mar 6, 2019 at 7:12

3 Answers 3


Use the describeGlobal() API call:https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_describeglobal_describeglobalresult.htm

Run the below code in Execute anonymous and check debug. You will get all the sobject name(API Name), label and other properties.

 for ( Schema.SObjectType o : Schema.getGlobalDescribe().values() )
        Schema.DescribeSObjectResult objResult = o.getDescribe();
        system.debug( 'Sobject: ' + objResult );
        system.debug( 'Sobject API Name: ' + objResult.getName() );
        system.debug( 'Sobject Label Name: ' + objResult.getLabel() );   

Update: You can count the record update by the below code, but the problem is, not all object is countable. And for this, you have to exclude those objects

for ( Schema.SObjectType o : Schema.getGlobalDescribe().values() )

        Schema.DescribeSObjectResult objResult = o.getDescribe();
        system.debug( 'Sobject API Name: ' + objResult.getName() );

        String obj = objResult.getName();
        if('EmailStatus' == obj || obj == 'Name' || obj == 'Vote' || obj == 'AggregateResult'
          || obj == 'CampaignChangeEvent' || obj == 'AccountChangeEvent' || obj == 'ContactChangeEvent'
           || obj == 'LeadChangeEvent' || obj == 'OpportunityChangeEvent' || obj == 'OpportunityContactRoleChangeEvent' 
           ||  obj == 'Product2ChangeEvent' || obj == 'AssetChangeEvent' || obj == 'CaseChangeEvent' || (... more conditions)

        String q = 'SELECT Count() FROM ' + obj;

        Integer count = Database.countQuery(q);

        System.Debug(objResult.getName() + '-->' + count);

  • Hi Noor, thank you for the quick update. How do I get the " record counts " associated to each Objects (Standard & Custom)?
    – Sri
    Mar 6, 2019 at 7:05
  • Awesome, thank you Noor - one more question :) ; can we get list of NON countable objects that I can filter in your code above :-)
    – Sri
    Mar 6, 2019 at 8:56

As per the comments by OP, org migration doesn't require one to write custom code to know standard and custom objects, fields, and records associated with them.

To know standard and custom objects:

  1. Workbench
    • info > Standard & Custom Objects
    • field information can also be found in the details

enter image description here

  1. Switch to Lightning experience, and goto Object manager where you have a complete list of objects, both standard and custom. I use this all the time to estimate migration effort. List the objects with no of fields for estimation (can also be done through Classic but more time taking).

To know the no of records in each object

  1. Salesforce data loader - use export operation to export each object's data and get an idea regarding number of records and its structure.
  2. SOQL - if only the no. of records for each object matter to you, sometimes for ball-park estimate, and you don't want to run the export entire data via dataloader, run SELECT count(id) FROM [object] and it will give you count of records. Do the same for other objects.
  • Thank you Mahmood, but the situation I have is, we have > 1TB of data and ~800+ objects (per OOB listing) , getting the record counts and querying each object is time consuming, so I was looking for workaround to get the accurate list of objects (custom & standard) + record counts...
    – Sri
    Mar 6, 2019 at 8:52

I used the below approach:

  1. log in to Workbench
  2. Go to Utilities > Rest Explorer
  3. Do a GET call on this URI: /services/data/v56.0/limits/recordCount ( replace 56.0 with the latest API version)
  4. Check the result. Copy the JSON and convert it to CSV


  1. The Rest call result does not include uncountable objects and record count for deleted records in the recycle bin
  2. Ensure your user has "View Setup and Configuration” permission

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .