Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Retrieve, Update and Delete Entities

[Applies to: Microsoft Dynamics CRM 2011]

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

In This Topic

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 sampleuses the DeleteEntityRequest 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 2011
Send comments about this topic to Microsoft.
© 2013 Microsoft Corporation. All rights reserved.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.