The CRM 2011 SDK documents this process here:
It also includes a very important note:
Do not use the etc (entity type code) parameter that contains an integer code for the entity. This integer code varies for custom entities in different organizations.
One of the required parameters on a Dynamics CRM URL is the type of entity you’re opening. This is specified by one of these parameters:
- etc – for Entity Type Code
- etn – for Entity Type Name
In Dynamics CRM 4.0, (and 3.0 for that matter), most people used the etc parameter. This cause some very bad side-effects when moving your code from installation to installation (development, test, production). The Entity Type Code could, and often did, vary from installation to installation.
etn, the second parameter, allows you to specify the name of the entity: account, contact, new_entity, etc. This information does not change from installation to installation.
I once saved 30 minutes per roll-out by switching all of my URL references from etc to etn. Before that, I had to hand-modify my code to reference the proper Entity Type Code and had to maintain an Excel worksheet with that information.
etn has been around since at least CRM 4.0 but you can save yourself a lot of trouble in the future, by converting your code from etc to etn.
Problems and Issues
I ran into an unexpected situation during an upgrade that quite honestly, left me a bit baffled. It seems a breaking change was introduced during the CRM 2011 upgrade process.
In CRM 4.0, you could open an Entity record with either one of the following URLs:
The difference being using the parameter etn (entity type name) instead of etc (entity type code). Using etn is preferable because it causes fewer issues when migrating from one system to another (development, test, production).
This technique is used extensively in an xRM scenario where you may have additional web pages that use or reference CRM data. It is common to have a screen artifact, like a button, that will open a CRM record when pressed and the URLs listed above are what is used.
It would seem that the etn parameter is no longer supported by the edit.aspx page in CRM 2011 for what appears to be custom entities only. It seems to work fine for out-of-the-box entities.
The use of etn is ONLY supported on main.aspx, AND you need to specify the &pagetype=entityrecord parameter, like this:
I am sure you have noticed, and maybe used, the Copy a Link/Email a Link functionality built into CRM:
This is a very handy feature and I use it all of the time.
Unfortunately, it will return a different URL depending on the entity being used. Standard entities will produce a URL with main.aspx while custom entities will produce edit.aspx.
And again, only main.aspx can use the etn parameter.
I cover this topic a little more in this article:
and I’ll update that article to reflect this new information.