function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Gage Staruch 9Gage Staruch 9 

Help reading/understaning batch apex class

Hey everyone!

I'm trying to wrap my head around this apex class.

We've been trying to figure out what exactly is causing some tasks to auto-complete. I believe its this class, but not entirely sure as I havent worked with the database.batchable method. 

Could someone help me understand what this class does?

 

global class TaskRelatedToAssignerBatch implements Database.Batchable<sObject> {
    
    global Database.Querylocator start (Database.BatchableContext BC) {
		Date today = System.today();
        Date yesterday = today.addDays(-1);
        return Database.getQueryLocator('SELECT Id, WhoId, WhatId, CreatedDate FROM Task WHERE ((Status = \'Completed\' AND Subject LIKE \'Email:%\') OR RecordTypeId = \'0125A000000tbd5\') AND (WhatId = null OR WhatId_String__c LIKE \'001%\') AND WhoId != null AND CreatedDate >= :yesterday');
   }
    
    global void execute (Database.BatchableContext BC, List<sobject> scope) {
        TaskUtils.relateTasksToOpportunityOrAccount(scope);
    }
    
    global void finish(Database.BatchableContext BC) {}

}

Thank you!
Boss CoffeeBoss Coffee
Do you know what the following method does? Without it, I'm unsure what actions are being taken on the list of Tasks.
TaskUtils.relateTasksToOpportunityOrAccount(scope);