Get Object Type Code for entities in Dynamics CRM

Welcome to my old Blogspot blog! You can read this post on our new website: Read this post on our new website 

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 retrieve 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

3 comments: