Export (0) Print
Expand All
Expand Minimize

BulkDelete Message (CrmService)

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Works for all deployment typesWorks online only

Submits an asynchronous bulk delete job.

The relevant classes are specified in the following table.

TypeClass
RequestBulkDeleteRequest
ResponseBulkDeleteResponse
EntitySee below.
Optional ParametersRegardingObjectIdOptionalParameter

RequestIdOptionalParameter


The following table shows the entities for this message.

Entity
account
activitymimeattachment
annotation
annualfiscalcalendar
appointment
asyncoperation
attributemap
bulkdeleteoperation
bulkoperation
businessunitnewsarticle
calendar
campaign
campaignactivity
campaignresponse
columnmapping
competitor
constraintbasedgroup
contact
contract
contractdetail
contracttemplate
customeraddress
customeropportunityrole
customerrelationship
discount
discounttype
duplicaterule
duplicaterulecondition
DynamicEntity
email
equipment
fax
fixedmonthlyfiscalcalendar
import
importfile
importmap
incident
incidentresolution
invoice
invoicedetail
isvconfig
kbarticle
kbarticlecomment
kbarticletemplate
lead
letter
list
lookupmapping
mailmergetemplate
monthlyfiscalcalendar
opportunity
opportunityclose
opportunityproduct
orderclose
ownermapping
phonecall
picklistmapping
pluginassembly
plugintype
pricelevel
product
productpricelevel
quarterlyfiscalcalendar
queue
quote
quoteclose
quotedetail
relationshiprole
relationshiprolemap
report
reportcategory
reportentity
reportvisibility
resourcespec
role
salesliterature
salesliteratureitem
salesorder
salesorderdetail
savedquery
sdkmessageprocessingstep
sdkmessageprocessingstepimage
sdkmessageprocessingstepsecureconfig
semiannualfiscalcalendar
service
serviceappointment
site
subject
task
template
territory
transactioncurrency
transformationmapping
transformationparametermapping
uom
uomschedule
userquery
workflow
workflowdependency
workflowlog
DynamicEntity
Custom entity

Remarks

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

To perform this action, the caller must have Read access rights on the entity instances specified in the request class. For a list of required privileges, see BulkDelete Privileges. By default, a System Administrator has the BulkDelete privileges. Other users have to be granted the BulkDelete privileges to perform a bulk delete operation.

Example

The following code example shows how to start a bulk delete job.

[C#]
// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
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 a query expression that retrieves all accounts.
QueryExpression accountsQuery = new QueryExpression();
accountsQuery.EntityName = EntityName.account.ToString();
// Be aware that using AllColumns may adversely affect
// performance and cause unwanted cascading in subsequent 
// updates. A best practice is to retrieve the least amount of 
// data required.
accountsQuery.ColumnSet = new AllColumns();

// Create a query expression that retrieves all contacts.
QueryExpression contactsQuery = new QueryExpression();
contactsQuery.EntityName = EntityName.contact.ToString();
// Be aware that using AllColumns may adversely affect
// performance and cause unwanted cascading in subsequent 
// updates. A best practice is to retrieve the least amount of 
// data required.;
contactsQuery.ColumnSet = new AllColumns()

// Create a request.
BulkDeleteRequest request = new BulkDeleteRequest();
request.JobName = "Delete all accounts and contacts";
request.QuerySet = new QueryBase[] { accountsQuery, contactsQuery }; 
request.SendEmailNotification = false;
request.ToRecipients = new Guid[0];
request.CCRecipients = new Guid[0];
request.RecurrencePattern = string.Empty;
request.StartDateTime = new CrmDateTime();
request.StartDateTime.Value = DateTime.Now.ToString("s");

// Execute the request.
BulkDeleteResponse response = (BulkDeleteResponse)service.Execute(request);
Guid jobId = response.JobId;
[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 a query expression that retrieves all accounts
Dim accountColumns As New ColumnSet()
accountColumns.Attributes = New String() {"name"}

Dim accountIdsCondition As New ConditionExpression()
accountIdsCondition.AttributeName = "accountid"
accountIdsCondition.Operator = ConditionOperator.In
accountIdsCondition.Values = New Object() {accountIds(0), accountIds(1), accountIds(2)}

Dim accountIdsFilter As New FilterExpression()
accountIdsFilter.Conditions = New ConditionExpression() {accountIdsCondition}

Dim accountsQuery As New QueryExpression()
accountsQuery.EntityName = EntityName.account.ToString()
accountsQuery.ColumnSet = accountColumns
accountsQuery.Criteria = accountIdsFilter

' Create a query expression that retrieves all contacts
Dim contactColumns As New ColumnSet()
contactColumns.Attributes = New String() {"fullname"}

Dim contactIdsCondition As New ConditionExpression()
contactIdsCondition.AttributeName = "contactid"
contactIdsCondition.Operator = ConditionOperator.In
contactIdsCondition.Values = New Object() { contactIds(0), contactIds(1), contactIds(2)}

Dim contactIdsFilter As New FilterExpression()
contactIdsFilter.Conditions = New ConditionExpression() { contactIdsCondition }

Dim contactsQuery As New QueryExpression()
contactsQuery.EntityName = EntityName.contact.ToString()
contactsQuery.ColumnSet = contactColumns
contactsQuery.Criteria = contactIdsFilter

' Create a request
Dim request As New BulkDeleteRequest()
request.JobName = "Delete all accounts and contacts"
request.QuerySet = New QueryBase() { accountsQuery, contactsQuery }
request.SendEmailNotification = False
request.ToRecipients = New Guid(){}
request.CCRecipients = New Guid(){}
request.RecurrencePattern = String.Empty
request.StartDateTime = New CrmDateTime()
request.StartDateTime.Value = DateTime.Now.ToString("s")

' Execute the request
Dim response As BulkDeleteResponse = CType(service.Execute(request), BulkDeleteResponse)
Dim jobId As Guid = response.JobId

See Also

Concepts

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show:
© 2014 Microsoft