Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Get display names of attributes from a record

Posted on by 295

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

  • Abhishek Gupta Profile Picture
    Abhishek Gupta 2,001 on at
    RE: Get display names of attributes from a record

    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

  • RE: Get display names of attributes from a record

    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.

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Get display names of attributes from a record

    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.

  • Suggested answer
    Syed Ibrahim Profile Picture
    Syed Ibrahim 6,257 on at
    RE: Get display names of attributes from a record

    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.

  • Dynamics365 Rocker Profile Picture
    Dynamics365 Rocker 7,755 on at
    RE: Get display names of attributes from a record

    You have to use entity query expression class.

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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans