How To: Retrieve Entity Metadata In CRM Using C# SDK

Introduction : Suppose you would like any kind of Metadata  about an entity such as "IsCustomEntity","IsCustomizable","ObjectTypeCode" & "PrimaryNameAttribute".

Code:

//Create RetrieveEntityRequest
RetrieveEntityRequest retrievesEntityRequest = new RetrieveEntityRequest
{
EntityFilters = EntityFilters.Entity,
LogicalName = entityName
};

//Execute Request
RetrieveEntityResponse retrieveEntityResponse =(RetrieveEntityResponse)_serviceproxy.Execute(retrievesEntityRequest);

codeNote: you can find how to create service proxy at the following link http://crmprof.wordpress.com/2013/03/13/creating-organization-service-proxy-in-microsoft-dynamics-crm-2011/

2 thoughts on “How To: Retrieve Entity Metadata In CRM Using C# SDK”

  1. hi,
    i am c# developer,currently working on dynamic crm 2016.i have to create custom activity in crm using Microsoft.Xrm.Sdk version 8.0.
    i have created custom activity in crm using CreateEntityRequest but got an error regarding HasFeedback in 8.0 version ,
    but when i created custom activity with CreateEntityRequest version 5.0 then it will created successfully.but our goal is to create custom activity using Microsoft.Xrm.Sdk version 8.0.
    so please suggest me how to create custom activity in crm using Microsoft.Xrm.Sdk version 8.0.

    code:-
    using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(orgServiceManagement, creds))
    {
    // This statement is required to enable early-bound type support.
    serviceProxy.EnableProxyTypes();

    String customEntityName = "ClosingActivity1";

    CreateEntityRequest request = new CreateEntityRequest
    {
    HasActivities = true,
    HasNotes = true,
    HasFeedback = true,

    PrimaryAttribute = new StringAttributeMetadata
    {
    RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
    MaxLength = 100,
    DisplayName = new Label("Subject", 1033)
    },
    Entity = new EntityMetadata
    {

    IsActivityParty = true,
    HasChanged = true,

    SchemaName = customEntityName,
    DisplayName = new Label("Closing Activity", 1033),
    DisplayCollectionName = new Label("Closing Activity", 1033),
    IsAvailableOffline = true,
    }

    };
    serviceProxy.Execute(request);

    then got Unreconized HasFeedback error

    please give me solution ASAP.

Leave a Reply

Your email address will not be published. Required fields are marked *