Retrieve, update, and delete entities


Updated: November 29, 2016

Applies To: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online

This topic shows how to retrieve, update, and delete an entity by using the custom Bank Account entity created in Create a custom entity.

The following sample retrieves an entity by using the RetrieveEntityRequest message. It then updates the entity to disable mail merge by setting the IsMailMergeEnabled property to false, and sets HasNotes to true in the UpdateEntityRequest to specify that the entity should include a relationship to the Annotation entity so that the entity can display notes.

RetrieveEntityRequest retrieveBankAccountEntityRequest = new RetrieveEntityRequest
 EntityFilters = EntityFilters.Entity,
 LogicalName = _customEntityName
RetrieveEntityResponse retrieveBankAccountEntityResponse = (RetrieveEntityResponse)_serviceProxy.Execute(retrieveBankAccountEntityRequest);
EntityMetadata BankAccountEntity = retrieveBankAccountEntityResponse.EntityMetadata;

// Disable Mail merge
BankAccountEntity.IsMailMergeEnabled = new BooleanManagedProperty(false);
// Enable Notes
UpdateEntityRequest updateBankAccountRequest = new UpdateEntityRequest
 Entity = BankAccountEntity,
 HasNotes = true


The following sample uses the DeleteEntityRequest message to delete the entity with the logical name specified by the _customEntityName variable.

DeleteEntityRequest request = new DeleteEntityRequest()
 LogicalName = _customEntityName,

Microsoft Dynamics 365

© 2016 Microsoft. All rights reserved. Copyright

Community Additions