Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
![]() |
Deletes an entity instance.
Syntax
[Visual Basic]
Public Sub Delete(
ByVal entityName As String,
ByVal id As Guid
)
[C#]
public void Delete(
string entityName,
Guid id
);
[JScript]
public function Delete(
entityName : String,
id : Guid
);
Parameters
entityName
Specifies the name of the entity. See Entity Names.
id
Specifies the ID of the entity instance you want to delete.
Return Value
No return value.
Remarks
Use this method to delete any instance of a Microsoft CRM entity that supports the Delete message.
To perform this action, the caller must have the Delete privilege to the entity type and access rights on the entity instance specified in the request class.
See Cascading Rules for a description of how actions on a parent instance affect child instances.
Example
The following example demonstrates the use of the Delete method.
[C#]
// Set up the CRM Service.
CrmService service = new CrmService();
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
// contactGuid is the GUID of the record being deleted.
Guid contactGuid = new Guid("4D507FFE-ED25-447B-80DE-00AE3EB18B84");
// Delete the contact.
// The EntityName indicates the EntityType of the object being deleted.
service.Delete(EntityName.contact.ToString(), contactGuid);
[Visual Basic .NET]
' Set up the CRM Service.
Dim service As New CrmService()
service.Credentials = System.Net.CredentialCache.DefaultCredentials
' contactGuid is the GUID of the record being deleted.
Guid contactGuid = new Guid("4D507FFE-ED25-447B-80DE-00AE3EB18B84");
' Delete the contact.
' The EntityName indicates the EntityType of the object being deleted.
service.Delete(EntityName.contact.ToString(), contactGuid)
See Also