Export (0) Print
Expand All

CrmService.Delete Method

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Deletes an entity instance.

Syntax

[Visual Basic .NET]
Public Sub Delete(
  ByVal entityName As String,
  ByVal id As Guid
)
[C#]
public void Delete(
  string  entityName,
  Guid  id
);

Parameters

entityName

Specifies a String containing the name of the entity. For more information, see Using Entity Names.

id

Specifies a GUID containing 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 Dynamics CRM entity that supports the Delete message.

For better performance, use this method instead of using the Execute method with the Delete message.

To perform this action, the caller must have access rights on the entity instance specified in the request class. For a list of required privileges, see Delete Privileges.

For a description of how actions on a parent instance affect child instances, see Cascading Rules.

Example

The following example demonstrates the use of the Delete method.

[C#]
// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0; 
token.OrganizationName = "AdventureWorksCycle";
 
CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
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 token As New CrmAuthenticationToken()
' You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Dir3ectory authentication.
token.AuthenticationType = 0
token.OrganizationName = "AdventureWorksCycle";
 
Dim service As New CrmService()
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
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

Concepts

Tasks

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show:
© 2014 Microsoft