Delete Message (CrmService)

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Find the latest SDK documentation: CRM 2015 SDK

Works for all deployment types Works online and offline

Deletes a business entity instance.

The relevant classes are specified in the following table.

Type Class
Request DeleteRequest
Response DeleteResponse
Target TargetDelete
Entity See the following table.

The following table shows the entities and target classes for this message.

Entity Target class
Custom entity TargetDeleteX where X is the name of the entity
account TargetDeleteAccount
activitymimeattachment TargetDeleteActivityMimeAttachment
annotation TargetDeleteAnnotation
annualfiscalcalendar TargetDeleteAnnualFiscalCalendar
appointment TargetDeleteAppointment
asyncoperation TargetDeleteAsyncOperation
attributemap TargetDeleteAttributeMap
bulkdeleteoperation TargetDeleteBulkDeleteOperation
bulkoperation TargetDeleteBulkOperation
businessunitnewsarticle TargetDeleteBusinessUnitNewsArticle
calendar TargetDeleteCalendar
campaign TargetDeleteCampaign
campaignactivity TargetDeleteCampaignActivity
campaignresponse TargetDeleteCampaignResponse
columnmapping TargetDeleteColumnMapping
competitor TargetDeleteCompetitor
constraintbasedgroup TargetDeleteConstraintBasedGroup
contact TargetDeleteContact
contract TargetDeleteContract
contractdetail TargetDeleteContractDetail
contracttemplate TargetDeleteContractTemplate
customeraddress TargetDeleteCustomerAddress
customeropportunityrole TargetDeleteCustomerOpportunityRole
customerrelationship TargetDeleteCustomerRelationship
discount TargetDeleteDiscount
discounttype TargetDeleteDiscountType
duplicaterule TargetDeleteDuplicateRule
duplicaterulecondition TargetDeleteDuplicateRuleCondition
DynamicEntity TargetDeleteDynamic
email TargetDeleteEmail
equipment TargetDeleteEquipment
fax TargetDeleteFax
fixedmonthlyfiscalcalendar TargetDeleteFixedMonthlyFiscalCalendar
import TargetDeleteImport
importfile TargetDeleteImportFile
importmap TargetDeleteImportMap
incident TargetDeleteIncident
incidentresolution TargetDeleteIncidentResolution
invoice TargetDeleteInvoice
invoicedetail TargetDeleteInvoiceDetail
isvconfig TargetDeleteIsvConfig
kbarticle TargetDeleteKbArticle
kbarticlecomment TargetDeleteKbArticlecomment
kbarticletemplate TargetDeleteKbArticletemplate
lead TargetDeleteLead
letter TargetDeleteLetter
list TargetDeleteList
lookupmapping TargetDeleteLookUpMapping
monthlyfiscalcalendar TargetDeleteMonthlyFiscalCalendar
opportunity TargetDeleteOpportunity
opportunityclose TargetDeleteOpportunityClose
opportunityproduct TargetDeleteOpportunityProduct
orderclose TargetDeleteOrderClose
ownermapping TargetDeleteOwnerMapping
phonecall TargetDeletePhoneCall
picklistmapping TargetDeletePickListMapping
pluginassembly TargetDeletePluginAssembly
plugintype TargetDeletePluginType
pricelevel TargetDeletePriceLevel
product TargetDeleteProduct
productpricelevel TargetDeleteProductPriceLevel
quarterlyfiscalcalendar TargetDeleteQuarterlyFiscalCalendar
queue TargetDeleteQueue
quote TargetDeleteQuote
quoteclose TargetDeleteQuoteClose
quotedetail TargetDeleteQuoteDetail
relationshiprole TargetDeleteRelationshipRole
relationshiprolemap TargetDeleteRelationshipRoleMap
report TargetDeleteReport
reportcategory TargetDeleteReportCategory
reportentity TargetDeleteReportEntity
reportvisibility TargetDeleteReportVisibility
resourcespec TargetDeleteResourceSpec
role TargetDeleteRole
salesliterature TargetDeleteSalesLiterature
salesliteratureitem TargetDeleteSalesLiteratureItem
salesorder TargetDeleteSalesOrder
salesorderdetail TargetDeleteSalesOrderDetail
savedquery TargetDeleteSavedQuery
sdkmessageprocessingstep TargetDeleteSdkMessageProcessingStep
sdkmessageprocessingstepimage TargetDeleteSdkMessageProcessingStepImage
sdkmessageprocessingstepsecureconfig TargetDeleteSdkMessageProcessingStepSecureConfig
semiannualfiscalcalendar TargetDeleteSemiAnnualFiscalCalendar
service TargetDeleteService
serviceappointment TargetDeleteServiceAppointment
site TargetDeleteSite
subject TargetDeletesubject
task TargetDeleteTask
template TargetDeleteTemplate
territory TargetDeleteTerritory
transactioncurrency TargetDeleteTransactionCurrency
transformationmapping TargetDeleteTransformationMapping
transformationparametermapping TargetDeleteTransformationParameterMapping
uom TargetDeleteUoM
uomschedule TargetDeleteUoMSchedule
userquery TargetDeleteUserQuery
workflow TargetDeleteWorkflow
workflowdependency TargetDeleteWorkflowDependency
workflowlog TargetDeleteWorkflowLog

Remarks

To use this message, pass an instance of the DeleteRequest class as the request parameter in the Execute method.

When an entity instance is deleted, all child objects of the instance are also deleted. The entire deletion fails if the caller does not have the delete privilege for any of these child objects.

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

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 better performance, use the Delete method instead of using this message.

Example

The following code example demonstrates how to delete a business entity instance.

[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;

// Create the target object for the request.
TargetDeleteAccount target = new TargetDeleteAccount();
// EntityId is the GUID of the record being deleted.
target.EntityId = new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");

// Create the request object.
DeleteRequest delete = new DeleteRequest();
delete.Target = target;

// Execute the request.
DeleteResponse deleted = (DeleteResponse)service.Execute(delete);

[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 Directory 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

' Create the target object for the request.
Dim target As New TargetDeleteAccount()
' EntityId is the GUID of the record being deleted.
target.EntityId = New Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");

' Create the request object.
Dim delete As New DeleteRequest()
delete.Target = target

' Execute the request.
Dim deleted As DeleteResponse = CType(service.Execute(delete), DeleteResponse)

See Also

Reference

© 2010 Microsoft Corporation. All rights reserved.