September 7, 2009

Link to custom entity – use of etn instead of etc argument

If you want to create a direct link to an out-of-a-box entity it is a very simple task: Right-click on one instance (let’s say account) and select “Copy Shortcut”.

image

Then just just change the GUID in the URL to open desired account. For the Account this URL looks like this: http://SERVER:PORT/OrganizationName/sfa/accts/edit.aspx?id={GUID}

Custom entities

All custom entities have the same URL structure: http://SERVER:PORT/OrganizationName/userdefined/edit.aspx?id={GUID}&etc=EntityTypeCode

Notice the entity type code? This code is created when creating the entity. But for some reason Entity Type Code can be (in most cases) different on every CRM instance. This means that if you are creating a plugin that needs to create a link to the entity, you will have to query metadata to get the code or enter that code in configuration part.

But there is a better way:

Instead of “etc” argument you can use “etn” (Entity Name) in the query string. Then use the logical name of the entity. Logical name is the same on all instances.

http://SERVER:PORT/OrganizationName/userdefined/edit.aspx?id={GUID}&etn=EntityName

http://testsrv:5555/Contoso/userdefined/edit.aspx?id={08B91EBF-525A-DE11-94A6-002354F5ABA2}&etn=new_testentity

1 comment:

Yeray said...

Hi..I have a problem with this... Dont work.I tried a Javascript code as this:

crmForm.all.IFRAME_a.src="http://SERVER/NAME_ORG/userdefined/edit.aspx?etn=NAME_CUSTOM_ENITY&id={GUID_SPECIFIC_CUSTOM_ENTITY}";

But the iframe doesnt work. The iframe say me that i havent permission od security for get this entity. Any idea?