{Dynamics CRM} Get EntityTypeCode of an entity in CRM 2013 using JScript

Recently in my project i was required to get the entity type code of entity. A little bit of searching and I could find multiple ways to get them in jscript.

However the main problems were:

1. they were working only on entity forms

2. you would have to make a metadata call to get the objecttypecode

To overcome both of this in CRM 2013, you could use the Xrm.Internal namespace. Please note that this is not a documented api by Microsoft to be used by the end users.

However it exposes some utility functions which you can use. Of them i used the Xrm.Internal.getEntityCode(“<entitylogicalname>”) method.

For e.g – Xrm.Internal.getEntityCode(“account”) would return you 1.

And this is not restricted to Form only. You can use it anywhere in the context of CRM.

To explore other methods of this namespace, refer to this link –



Hope this helps!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s