Michael Philip's Blog

Writing about MS Tech with strong focus on Azure & CRM

How To: Retrieve Entity Metadata Using .NET in Microsoft Dynamics CRM 2011

2 Comments

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 https://crmprof.wordpress.com/2013/03/13/creating-organization-service-proxy-in-microsoft-dynamics-crm-2011/

Advertisements

2 thoughts on “How To: Retrieve Entity Metadata Using .NET in Microsoft Dynamics CRM 2011

  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.

  2. what if I want to retrieve the metadata of a process
    and thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s