locked
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

    http://stackoverflow.com/questions/7361856/crm-2011-get-custom-entity-record-attribute-without-early-bound-types

    https://community.dynamics.com/crm/b/mileyja/archive/2012/04/03/retrieve-metadata-for-an-entity-in-microsoft-dynamics-crm-2011-using-vb-net.aspx


    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.
    http://stackoverflow.com/questions/12403344/find-out-the-names-of-all-the-attributes-in-an-entity-returned-from-crm-dynamics
    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
    Moderator
  • 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.

    thanks

    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.

    http://microsoftcrmworld.blogspot.com/2014/01/read-entity-attributes-in-ms-crm-2011.html


    Monday, February 24, 2014 3:23 PM