Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Retrieve, update, and delete entities

Retrieve, update, and delete entities

Applies To: CRM 2015 on-prem, 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.

Retrieve and update an 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
};



_serviceProxy.Execute(updateBankAccountRequest);

Delete a custom entity

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,
};
_serviceProxy.Execute(request);

See Also

Microsoft Dynamics CRM 2015 and Microsoft Dynamics CRM Online
Send comments about this topic to Microsoft.
© 2015 Microsoft. All rights reserved.
Show:
© 2015 Microsoft