• Aman Bhalla
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hi All,

First time playing around with Developer Console. I'm trying to delete all Tasks that have been created by a user (85,000 records). I can't use Data Loader since it will max out the number of records I want to delete so instead, I was able to create a query to find all the records. I'm now trying to use APEX Code to delete all the records listed and am having some trouble.

I am trying to find all tasks that were created by a user where the subject line does not equal "Initial Lead Notification Sent" or "Secondary Lead Notification Sent". Once its executed and I have a list, I would like to delete all records. Here's what I have so far:

APEX CODE
// fetching all Tasks Records via SOQL
List<task> TaskList = new List<task>();
TaskList = [SELECT Id, subject, WhoID, ActivityDate, FROM
   task WHERE CreatedByID = '0051400000Bazbn' AND subject != 'Initial Lead Notification Sent' AND subject != 'Secondary Lead Notification Sent'];
// SOQL query for given criteria

// Delete the fetched records
delete [SELECT Id FROM TaskList LIMIT 1000];

SOQL
select id, subject, WhoID, ActivityDate FROM task where CreatedByID = '0051400000Bazbn' AND subject != 'Initial Lead Notification Sent' AND subject != 'Secondary Lead Notification Sent'

Error:
Row 3 column 10, Unexpected token "=".
Hi All,

First time playing around with Developer Console. I'm trying to delete all Tasks that have been created by a user (85,000 records). I can't use Data Loader since it will max out the number of records I want to delete so instead, I was able to create a query to find all the records. I'm now trying to use APEX Code to delete all the records listed and am having some trouble.

I am trying to find all tasks that were created by a user where the subject line does not equal "Initial Lead Notification Sent" or "Secondary Lead Notification Sent". Once its executed and I have a list, I would like to delete all records. Here's what I have so far:

APEX CODE
// fetching all Tasks Records via SOQL
List<task> TaskList = new List<task>();
TaskList = [SELECT Id, subject, WhoID, ActivityDate, FROM
   task WHERE CreatedByID = '0051400000Bazbn' AND subject != 'Initial Lead Notification Sent' AND subject != 'Secondary Lead Notification Sent'];
// SOQL query for given criteria

// Delete the fetched records
delete [SELECT Id FROM TaskList LIMIT 1000];

SOQL
select id, subject, WhoID, ActivityDate FROM task where CreatedByID = '0051400000Bazbn' AND subject != 'Initial Lead Notification Sent' AND subject != 'Secondary Lead Notification Sent'

Error:
Row 3 column 10, Unexpected token "=".