Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

BulkDelete - Object reference not set to an instance of an object

(0) ShareShare
ReportReport
Posted on by 255

Hi

Can any tell me where I'm going wrong here?

Dim deleteCondition = New ConditionExpression("my_id", ConditionOperator.Equal, appID)
Dim deleteFilter = New FilterExpression()
deleteFilter.Conditions.Add(deleteCondition)

Dim bulkDeleteQuery = New QueryExpression()
bulkDeleteQuery.EntityName = "my_entity"
bulkDeleteQuery.Distinct = False
bulkDeleteQuery.Criteria = deleteFilter

Dim bulkDeleteRequest = New BulkDeleteRequest()
bulkDeleteRequest.JobName = "Bulk Delete Study Choice " & appGuid
bulkDeleteRequest.QuerySet = New QueryExpression() {bulkDeleteQuery}
bulkDeleteRequest.StartDateTime = Date.Now
bulkDeleteRequest.RecurrencePattern = String.Empty
bulkDeleteRequest.SendEmailNotification = False
bulkDeleteRequest.ToRecipients = New Guid() {}
bulkDeleteRequest.CCRecipients = New Guid() {}

service.Execute(bulkDeleteRequest)

  • Mohsin Ali Profile Picture
    Mohsin Ali 3,610 on at
    RE: BulkDelete - Object reference not set to an instance of an object

    Your source code looks good, but somehow assumptions are that job name don't exists in CRM. Please make sure you already have available.

    Helpful?? Please mark my solution as verified.

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: BulkDelete - Object reference not set to an instance of an object

    HI,

    It looks good to me. I did compare your code with Sample code provided by Microsoft.

    github.com/.../SampleMethods.cs

    One thing you can check if service is not null.

    Please mark my answer verified if i were helpful

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans