Get Entities Object Type Code in Dynamics CRM

This post will help you to get object type code in dynamics CRM


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 Object Type Code 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

CRM Online

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

for Custom Entities:

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

Leave a Reply