How to Retrieve Entity Attribute type and value C# RRS feed

  • Question

  • hi ,
    i need to retrieve all attribute type , value from an entity record using c#.
    Can you Plz send some  sample code.
    Monday, February 24, 2014 11:09 AM

All replies

  • Are you trying for web to crm or for plugin?
    Monday, February 24, 2014 11:23 AM
  • check this



    ms crm

    Monday, February 24, 2014 11:23 AM
  • Hi ,
    I am using a plugin , i am retrieveing all attribute , 
    but i need to find each attribute type and then get value.
    eg : If Look up means something using like "Microsoft.Xrm.Sdk.EntityReference"

    Some Sample links i found.
    Monday, February 24, 2014 12:10 PM
  • Hello,

    You should be able to get it just by GetType() method, for example AttributeName.GetType() will provide you it's data type.

    Check this:https://community.dynamics.com/crm/b/c5insightblog/archive/2011/03/04/dynamics-crm-2011-reading-attribute-values-inside-your-plug-in.aspx

    Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Monday, February 24, 2014 12:20 PM
  • foreach (Entity entity in result.Entities) { foreach (KeyValuePair<String, Object> attribute in entity.Attributes) { Console.WriteLine(attribute.Key + ": " + attribute.Value); } }

    this is an sample . but i need to modify the code, to retrieve option set , look up , money field.

    can u plz send some sample code.

    Monday, February 24, 2014 12:20 PM
  • Hi ,

    I am looking like the same example ,
    in that retrieve method , need to exactly retrieve attribute type ,
    eg: Look Up , 
    Logical Name , ID , attribute type.

    and i need to send as array type of each attribute.
    so that i can read all attribute meta data , value and type.


    Monday, February 24, 2014 12:27 PM
  • You'll need to execute a "RetrieveEntityRequest" and loop through all the AttributeMetadata from the RetrieveEntityResponse.EntityMetadata.Attributes.

    Check out the following sample code which will suit your requirement.


    Monday, February 24, 2014 3:23 PM