Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

EntityMetadata.DisplayName.UserLocalizedLabel is null

$
0
0

Why EntityMetadata.DisplayName.UserLocalizedLabel is null for some entities?

public List<ValuesResponseData> Entities(IOrganizationService service)
        {
            RetrieveAllEntitiesRequest retrieveEntities = new RetrieveAllEntitiesRequest()
            {
                EntityFilters = EntityFilters.Attributes,
                RetrieveAsIfPublished = true
            };
            RetrieveAllEntitiesResponse retrieveEntitiesResponse = (RetrieveAllEntitiesResponse)service.Execute(retrieveEntities);
            

            EntityMetadata[] entityMetadatas = retrieveEntitiesResponse.EntityMetadata;
            List<ValuesResponseData> entityresponsedata = new List<ValuesResponseData>();
            
            for(int i = 0; i < entityMetadatas.Length; i++)
            {
                ValuesResponseData tempEntityResponse = new ValuesResponseData();
                if (entityMetadatas[i].DisplayName.UserLocalizedLabel != null)
                {
                    tempEntityResponse.Nome = entityMetadatas[i].DisplayName.UserLocalizedLabel.Label.ToString().Replace('"', '\'');
                    tempEntityResponse.LogicalName = entityMetadatas[i].LogicalName;
                    tempEntityResponse.PrimaryName = entityMetadatas[i].PrimaryNameAttribute;
                    entityresponsedata.Add(tempEntityResponse);
                }
            }
            

            return entityresponsedata;
        }

After I execute this code, I don't get the list of all entities because for some of them 
DisplayName.UserLocalizedLabel is null.

Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>