<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:blog="http://dnn-connect.org/blog/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/">
  <channel>
    <title>Blog - MetaData service</title>
    <link>https://www.xrmlabs.com/About-Us/XRMs-Blog/term/100/locale/en-US/Blog-MetaData-service</link>
    <description />
    <managingEditor>sales@xrmlabs.com</managingEditor>
    <pubDate>Thu, 09 Apr 2026 04:17:18 GMT</pubDate>
    <lastBuildDate>Thu, 09 Apr 2026 04:17:18 GMT</lastBuildDate>
    <category>MetaData service</category>
    <generator>DotNetNuke Blog RSS Generator Version 6.5.2.0</generator>
    <ttl>30</ttl>
    <atom:link href="https://www.xrmlabs.com/DesktopModules/Blog/API/RSS/Get?moduleid=440&amp;tabid=94&amp;term=100" rel="self" type="application/rss+xml" />
    <item>
      <title>MS CRM 2011 Retrieving Entity Type Code or ETC</title>
      <link>https://www.xrmlabs.com/About-Us/XRMs-Blog/Post/232/MS-CRM-2011-Retrieving-Entity-Type-Code-or-ETC</link>
      <description>If you are looking to get the Entity Type Code or ETC (as it is generally known as) dynamically for any entity name in your&amp;nbsp;web resource&amp;nbsp;in MS &lt;a href="https://www.xrmlabs.com/Services/Custom-Implementation"&gt;CRM&lt;/a&gt;, you should use the MetaData service to do so. The MetaData service in MS &lt;a href="https://www.xrmlabs.com/Services/Custom-Implementation"&gt;CRM&lt;/a&gt; 2011 will retrieve all the Meta&amp;nbsp;information&amp;nbsp;about an entity. This information includes the display name of the entity, the logical name of the entity and all other information about its relationship status etc. However the information that we are interested in here is the "ObjectTypeCode".&amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
How to build your MetaData service? For building a MetaData&amp;nbsp;service you can use sample code provided in the &lt;a href="https://www.xrmlabs.com/Services/Custom-Implementation"&gt;CRM&lt;/a&gt; SDK itself. (samplecode\js\soapforjscript\soapforjscript\scripts). The name of the file is&amp;nbsp;sdk.metadata.js.&lt;br /&gt;
This javascript file has a function by name&amp;nbsp;RetrieveAllEntitiesAsync. This function fetches all the entities with with their MetaData&amp;nbsp;information. On success this function returns you&amp;nbsp;entityMetadataCollection. Now all you need to do is to loop over entities and get the Object Type Code. Please follow the code below to get the Object Type Code or ETC.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="reCodeBlock" style="border: 1px solid #7f9db9; overflow-y: auto;"&gt;
&lt;div style="background-color: #ffffff;"&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;function&lt;/code&gt; &lt;code style="color: #000000;"&gt;successRetrieveAllEntities(entityMetadataCollection) {&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 9px !important;"&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;for&lt;/code&gt; &lt;code style="color: #000000;"&gt;(&lt;/code&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;var&lt;/code&gt; &lt;code style="color: #000000;"&gt;i = 0; i &amp;lt; entityMetadataCollection.length; i++) {&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 18px !important;"&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;var&lt;/code&gt; &lt;code style="color: #000000;"&gt;entity = entityMetadataCollection[i];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 18px !important;"&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;var&lt;/code&gt; &lt;code style="color: #000000;"&gt;objTypeCode = entity.objectTypeCode;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 9px !important;"&gt;&lt;code style="color: #000000;"&gt;}&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="background-color: #f8f8f8;"&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000000;"&gt;}&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
This is a supported way of getting etc or ObjectTypeCode of an entity.&amp;nbsp;&lt;br /&gt;
Hope this helps.&amp;nbsp;</description>
      <category>Entity Type Code</category>
      <category>Javascript</category>
      <category>MetaData service</category>
      <category>MS CRM 2011</category>
      <category>ObjectTypeCode</category>
      <category>Javascript</category>
      <guid isPermaLink="true">https://www.xrmlabs.com/About-Us/XRMs-Blog/Post/232/MS-CRM-2011-Retrieving-Entity-Type-Code-or-ETC</guid>
      <pubDate>Fri, 19 Apr 2013 08:06:00 GMT</pubDate>
      <blog:publishedon>2013-04-19 08:06:00Z</blog:publishedon>
    </item>
  </channel>
</rss>