Sunday, December 9, 2012

Retrieve Entity Attributes Metadata

Problem:
              Need to get information regarding entity as well entity attributes.
Solution:
              As in my last post I have explain how to get meta data of the entities in the MS Dynamic CRM 2011, and get the information such as display name, schema name , description of the entities , now in this post I will explain how to get attributes information of each of the entity by providing entity name and then display the display name, schema name ,description and other properties of the attributes which an entity has.You can see the layout in Image 1, here you can see that I have provided search box to enter name of the entity to search the attributes and then when user select entity name (as I have use auto complete box of Silverlight , I have also provide the entity names so that user can easily search name of the entity by entering some of the initial character of the entity name).Then in the data grid control I have display information of the attribute which an entity has.


Image 01

Code to retrieve entity attribute meta data is listed in List 1, here you can see some of the difference of the code which I have used in my last post to get information of the entities.First thing which different is that request name here I have used the "RetrieveEntity" as request name, and then I have also mention the Attributes in the entity filter property of the request so that we can get attributes of the entity.Here you can see that in the Entity Filter attribute of the request I have mention both entity and attribute mean I want entity meta data and also attribute meta data of the entity which I am requesting.Next attribute of the request is the "LogicalName" , here I have provided schema name of the entity which user has selected from auto complete box.
List 1

Next is to send the request to retrieve the entity and entity attribute meta data , in the call back method I just loop through the attributes to get the properties like display name, schema name, description etch of the attributes which will be displayed in the data grid control. In the call back method I have just used the proper type name for attribute type which are displayed in the entity customization.
Downloads
You can download the source code of the sample from here.
and working CRM 2011 solution from here.

Go to Home

All and any comments / bugs / suggestions are welcomed!

No comments: