{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 –

https://debajitcrm.wordpress.com/2014/04/29/exploring-the-xrm-internal-namespace-in-crm-2013/

 

Hope this helps!

Advertisements

Author: Debajit

I am a Dynamics CRM Most Valuable Professional (MVP) with 10 years of experience in Microsoft .NET Technologies and 7 years of dedicated experience in Microsoft Dynamics CRM. I have worked with companies like Microsoft, SanDisk, PwC, TMF Group and have extensive experience of implementing complex CRM solutions from both offshore and client side. Currently the face of XrmForYou.com with significant experience in delivering corporate training on Dynamics CRM and have already delivered multiple projects to client through XrmForYou.com Author of multiple tools on codeplex including the 'Role Based Views' and 'CRM-Sharepoint Metadata manager & Attachment Extractor' which are available for commercial use under XrmForYou.com For consulting/ training, drop me a note at info@xrmforyou.com or visit our website www.xrmforyou.com

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s