MSCRM Development Tips & Tricks #4 – etc VS etn
In Microsoft CRM 4, when you open up the custom entity CRM form in edit mode, you will see the URL looks something like edit.aspx?etc=10020.
The 10020 represents the object type code number for the custom entity that we created. Generally speaking all entities in MS CRM has objecttypecode associated with them. However, for built-in entities, we don’t generally see it popping up on the querystring.
So let’s say you built an xRM solution that has a magic button. When the user click on this magic button, it will open up a CRM form for one of your custom entities. Your application need to know how to construct the correct URL for the CRM form to render. There are a number of ways to do this.
First, you can pass in the objecttypecode in the querystring so that it looks like the above example (etc=10020). While this looks like a reasonable approach, there are few issues attached to it. In order to get the objecttypecode, you will need to query the metadata service, which means an extra call to the service and therefore have a reasonable impact on the performance of your application. The bigger issue is objecttypecode is NOT transferable across multiple environment. So if you are working with multiple environment (eg: DEV, SIT, PROD), chances are your custom entity will have different objecttypecode on different environment.
So what’s the better approach? Here comes etn to the rescue! Instead of passing objecttypecode, you can pass in the logical name of your custom entity to the querystring. Now your querystring will look like etn=new_myentity. MSCRM will automatically recognize the etn querystring and display the form accordingly. This approach saves you from having to query the metadata service to retrieve the objecttypecode. On top of that, this approach works across multiple environment without having to change anything.
June 19th, 2010 - 11:26
So that’s:
etc = entity type Code
etn = entity type Name
(not sure if this is the real origin of them, but it’s a great way to remember them!)
June 20th, 2010 - 22:06
Yep. Exactly. etc and etn is just abbreviations.