Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Retrieve list of fields of a specific entity

(0) ShareShare
ReportReport
Posted on by 3,614

I can retrieve list of entities exists in CRM using this walkthrough but I also want to access list of fields of a specific entity. Such as Account, I want to have list of all fields of this entity.

Any suggestion or walkthrough on it.

*This post is locked for comments

  • Verified answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,076 on at
    RE: Retrieve list of fields of a specific entity

    Hi Mohsin Ali,

    Please correct the code as follows.

    RetrieveEntityRequest req= new RetrieveEntityRequest
    {
    EntityFilters = EntityFilters.All,
    LogicalName = "EntityLogicalName" // like "account"
    RetrieveAsIfPublished = true
    };
    RetrieveEntityResponse res= (RetrieveEntityResponse)_serviceProxy.Execute(req);
    EntityMetadata currentEntity = res.EntityMetadata;
    foreach(AttributeMetadata attribute in  currentEntity.Attributes)
    {
    var attributeName  = attribute .LogicalName;
    }
  • Suggested answer
    Andreas Cieslik Profile Picture
    Andreas Cieslik 9,267 on at
    RE: Retrieve list of fields of a specific entity

    Hi Mohsin Ali,

    Nithya started correct but you need to provide a different EntityFilter option:

    https://msdn.microsoft.com/en-us/library/microsoft.xrm.sdk.metadata.entityfilters.aspx

    Member nameDescription
    All

    Use this to retrieve all data for an entity. Value = 15.

    Attributes

    Use this to retrieve entity information plus attributes for the entity. Value = 2.

    Default

    Use this to retrieve only entity information. Equivalent to EntityFilters.Entity. Value = 1.

    Entity

    Use this to retrieve only entity information. Equivalent to EntityFilters.Default. Value = 1.

    Privileges

    Use this to retrieve entity information plus privileges for the entity. Value = 4.

    Relationships

    Use this to retrieve entity information plus entity relationships for the entity. Value = 8.

    Cheers,

    Andreas

  • Mohsin Ali Profile Picture
    Mohsin Ali 3,614 on at
    RE: Retrieve list of fields of a specific entity

    Thanks Gopinath. I've 31 fields so far in CRM for account but it shows I have null in attributes.

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,076 on at
    RE: Retrieve list of fields of a specific entity

    Hi Mohsin Ali,

    We can retreive all the attributes(fields) of an entity using the following code.

    RetrieveEntityRequest req= new RetrieveEntityRequest
    {
    EntityFilters = EntityFilters.Entity,
    LogicalName = "EntityLogicalName" // like "account"
    };
    RetrieveEntityResponse res= (RetrieveEntityResponse)_serviceProxy.Execute(req);
    EntityMetadata currentEntity = res.EntityMetadata;
    foreach(AttributeMetadata attribute in  currentEntity.Attributes)
    {
    var attributeName  = attribute .LogicalName;
    }


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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans