Peter Forsbom
Peter Forsbom

Reputation: 95

Get all Entities from Dynamics365 with code

I am trying to retrieve all entities from Dynamics 365 with code. Currently I am using RetrieveAllEntitiesRequest like this:

var metaDataRequest = new RetrieveAllEntitiesRequest();               
metaDataRequest.EntityFilters = EntityFilters.Attributes;
metaDataRequest.RetrieveAsIfPublished = true;
var metaDataResponse = (RetrieveAllEntitiesResponse)organizationProxy.Execute(metaDataRequest);

This code retrieves over 400 entities. My problem is that I only want to get the ones listed as Entities in the "Customize the System" dialog as shown in the picture below. Like Account, Activity, Address, Appointment.

The code I use returns entities like: accountleads, aciviewmapper,actioncardusersettings and I am not interested in those! I have tried looking through the EntityMetadata values but that did not give any clues to my problem.

Customize the System - Dialog

Upvotes: 0

Views: 768

Answers (1)

Normally we will keep a list of entity names in array to pull the Metadata instead of pulling everything.

Let's try this. I have used XrmToolBox - Metadata browser plugin to find out a common filter to use in your code, so that you will get the entity list only you want.

IsCustomizable, CanChangeTrackingBeEnabled, CanCreateViews, CanModifyAdditionalSettings gave me the hint we need. Dig more in this direction if you see a common criteria for your need.

enter image description here

Upvotes: 2

Related Questions