web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Get display names of attributes from a record

(0) ShareShare
ReportReport
Posted on by 297

Hello Everyone!

Hope this query finds you well and happy. I have an entity which has many fields. I fetched records of that entity by fetchxml query and in query i mentioned few fields and now i want to get display name of those fields which i mentioned in fetchxml at run-time so can anyone tell me how to do this ? How can i get display names of attributes from a record ?

*This post is locked for comments

I have the same question (0)
  • Dynamics365 Rocker Profile Picture
    7,755 on at

    You have to use entity query expression class.

    docs.microsoft.com/.../microsoft.xrm.sdk.metadata.query.entityqueryexpression

  • Suggested answer
    Syed Ibrahim Profile Picture
    6,257 on at

    Instead of fetch xml use queryExpression to get the display name of the fields..

    Follow the below code to to get the display names..

    [View:https://docs.microsoft.com/en-us/dotnet/api/microsoft.xrm.sdk.metadata.query.entityqueryexpression?view=dynamics-general-ce-9]

    Hope this helps.

    If your query got resolved, please make it as answered to close the thread.

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    Refer this blog-

    dynamics365blocks.wordpress.com/.../how-to-retrieve-display-name-of-an-attribute-in-dynamics-crm-using-c

    Code snippet from the blog-

    ====================

    public static string RetrieveAttributeDisplayName( string EntitySchemaName, string AttributeSchemaName, IOrganizationService service)

    {

    RetrieveAttributeRequest retrieveAttributeRequest = new RetrieveAttributeRequest

    {

    EntityLogicalName = EntitySchemaName,

    LogicalName = AttributeSchemaName,

    RetrieveAsIfPublished = true

    };

    RetrieveAttributeResponse retrieveAttributeResponse = (RetrieveAttributeResponse)service.Execute(retrieveAttributeRequest);

    AttributeMetadata retrievedAttributeMetadata = (AttributeMetadata)retrieveAttributeResponse.AttributeMetadata;

    //Get Length

    // Int32 length = (Int32)((Microsoft.Xrm.Sdk.Metadata.StringAttributeMetadata)retrievedAttributeMetadata).MaxLength;

    return retrievedAttributeMetadata.DisplayName.UserLocalizedLabel.Label;

    }

    ====================

    Hope this helps.

  • Microsoft Dynamics 365 Consultancy Profile Picture
    297 on at

    Kindly explain further how i get entity schema name and attribute schema name from following:

    EntityCollection fetchedRecordsCollection = service.RetrieveMultiple(new FetchExpression(finalQuery));

    tell me how i get entity schema name and attribute schema name from entity collection.

  • Abhishek Gupta Profile Picture
    2,003 on at

    hi,

    you can use below link to achieve this.

    Entity schema:

    dynamics365posts.home.blog/.../retrieve-crm-business-entities

    Attributes:

    dynamics365posts.home.blog/.../retrieve-crm-entity-attributes-list

    Thank you

    Abhishek

    If found useful, please mark the answer as verified

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans