Posted in CRM, Plugin

Retrieve All Entities Metadata

Retrieve All Entities Metadata

Contains the data that is needed to retrieve metadata information about all the entities.

If you are looking for getting the entity metadata using code (C#) then we have inbuilt messages to get all entities and if required attribute level information as well. You can use the message “RetrieveAllEntitiesRequest”.

//Microsoft.Xrm.Sdk.Messages.RetrieveAllEntitiesRequest

RetrieveAllEntitiesRequest request = new RetrieveAllEntitiesRequest(){
 EntityFilters = EntityFilters.Entity,
 RetrieveAsIfPublished = true
 };

 // Retrieve the MetaData.
RetrieveAllEntitiesResponse response = (RetrieveAllEntitiesResponse)service.Execute(request);

foreach (EntityMetadata currentEntity in response.EntityMetadata)
 {


}

 

If you need to get a specific entity information then you may use the message “RetrieveEntityRequest”

RetrieveEntityRequest Request = new RetrieveEntityRequest
{
    EntityFilters = EntityFilters.Attributes,
    LogicalName = entityName,
    RetrieveAsIfPublished = true
};
RetrieveEntityResponse entityResponse = (RetrieveEntityResponse)service.Execute(Request);

EntityFilters

Member name             Description

All                                 Retrieve all data for an entity. Value = 15.

Attributes                   Retrieve entity information plus attributes for the entity. Value = 2.

Default                        Retrieve only entity information. EntityFilters.Entity. Value = 1

Entity                          Retrieve only entity information. EntityFilters.Default. Value = 1

Privileges                   Retrieve entity information plus privileges for the entity. Value = 4.

Relationships            Retrieve entity information plus entity relationships  Value = 8.

Advertisements

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