In Microsoft Dynamics We Often need objectTypeCodes while doing data migration from CRM On-Premise to online.

If you have On-Premise CRM then you can query SQL database to get Object Type Codes for any entity. Below query will retrive entity logical name and objectTypeCode list for all OOB and Custom entities.

select Name, ObjectTypeCode from EntityView order by ObjectTypeCode


If you need Just for custom entities then just filter by object type code greator then 9999.

select Name, ObjectTypeCode from EntityView WHERE ObjectTypeCode>9999 order by ObjectTypeCode
                        

For CRM online you can retrieve objectTypeCodes by a Meta Data Call using Web API.

[org Url]/api/data/v8.2/EntityDefinitions?$select=LogicalName,ObjectTypeCode

Filter for Custom Entities:

[org Url]//api/data/v8.2/EntityDefinitions?$select=LogicalName,ObjectTypeCode&$filter=ObjectTypeCode gt 9999