web
You’re offline. This is a read only version of the page.
close
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,634

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

I have the same question (0)
  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    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;
    }


  • Mohsin Ali Profile Picture
    3,634 on at

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

  • Suggested answer
    Andreas Cieslik Profile Picture
    9,267 on at

    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

  • Verified answer
    Nithya Gopinath Profile Picture
    17,078 on at

    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;
    }

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans