What the hell is ObjectTypeCode (again) and where do I get it?

First of all, ObjectTypeCode isn’t used that often anymore and shouldn’t be used for any development. Unlike with previous versions of CRM 2011…

As the docs clearly states:

“Always use the entity schema name (SchemaName) to refer to a custom entity in code and queries. Do not use the object type code (also referred to as entity type) code because this integer value varies for custom entities in different organizations.”

https://docs.microsoft.com/en-us/dotnet/api/microsoft.xrm.sdk.metadata.entitymetadata.objecttypecode?view=dynamics-general-ce-9

Nevertheless, it can be helpful to quickly get a overview of all of the typecodes in the environment. For example, when tracing privilege problems. The logs will show “OTC=10080” which reference to the Object Type Code of a custom entity.

So know we know what it is

There used to be an easy way to get this from the URL like explained on https://www.powerobjects.com/blog/2018/06/22/find-object-type-code-entity/ but since the Unified interface uses the etn(EntityTypeName) now we had to come up with a different approach.

ObjectTypeCode bookmark button

Add the following to script to your bookmarks:

javascript:(function(){s=document.createElement('script');s.type='text/javascript';s.src='https://thrivesstorage.blob.core.windows.net/public/GetObjectTypeCodes.js';document.body.appendChild(s);})();
Now whenever you are on Dynamics 365 page, click the bookmark and a new page with an overview of the object type codes and the logical names will appear.

ObjectTypeCode overview page