Please wait, loading...

 

Get / Retrieve all Fields of an Entity in MSCRM using C# ( RetrieveEntityRequest )

September 1, 2015
Below Code Retrieve all Fields Of an Entity which can be used to perfore sevral execution Like bulk update of fields in an entity .

RetrieveEntityRequest aEntity = new RetrieveEntityRequest();
            aEntity.LogicalName = entityLogicanName;
          //only get published fields / attributes
            aEntity.RetrieveAsIfPublished = true;
            aEntity.EntityFilters = EntityFilters.All ;
            RetrieveEntityResponse resp = (RetrieveEntityResponse)service.Execute(aEntity);
            EntityMetadata getmetadata = resp.EntityMetadata;
            var crmAttributes = getmetadata.Attributes;
            attributes.Items.Clear();
            foreach (var attr in crmAttributes)
            {
                // filter can be used to get only Custom fields / or System fields with change
                if (attr.IsSecured == false && (attr.CanBeSecuredForUpdate == true || attr.CanBeSecuredForRead == true || attr.CanBeSecuredForCreate == true))
                    attributes.Items.Add(attr.LogicalName);
            }

Hope This Helped You Thanks For the Support , If Any query or suggestion , please comment below

SOURCE : JUST2CODE.IN Subscribe to our YouTube channel : https://www.youtube.com/user/TheRussell2012

https://i0.wp.com/microsoftdynamics.in/wp-content/uploads/2020/04/Microsoftdynamics365.png?fit=640%2C651
Microsoft Dynamics Community Profile

Learn more