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
Ty WhitfieldTy Whitfield 

Issue with Batch Apex

I've tried the code below (removed some items for confidentiality) but I receive the "made it to the query locator" debug message but never receive the "made it to the execute" debug.  I'm calling it by entering

batchGenerateAssets be = new batchGenerateAssets();
database.executeBatch(be);

in Execute Anonymous Window of the Developer Console

 

What am I doing wrong?

global class batchGenerateAssets implements Database.Batchable<sObject>, Database.AllowsCallouts{

 public String query = 'Select Id, PakSize__c, ProductFamily, UsageEndDate, Product2Id  FROM Asset WHERE SerialNumber = \'**Generate**\' ';

global Database.QueryLocator start(Database.BatchableContext BC)
{   
     System.debug('made it to querylocator');

    return Database.getQueryLocator(query);
}

global void execute(Database.BatchableContext BC, List<Asset> assetList) {
System.debug('made it to execute');
      
  ///////////////////////////////////////////////////////////////////////////////
    

      
}   
      global void finish(Database.BatchableContext BC)
      {
      }
}

 
Best Answer chosen by Ty Whitfield
Nihar ANihar A
Usually when batch apex is executed , there are multiple log files that are generated as the job is first queued and then executed. Make sure to check all the log files generated in dev console when you are running the job.

All Answers

Nihar ANihar A
Hi Ty,
Did you check if the query in your start method is fetching any data to send to execute method? I think the execute method might not be called if there is no data to be processed. I am not completely sure though. Please check that aspect.
Thanks.
Ty WhitfieldTy Whitfield

Yes, I do receive that 4 rows were returned which is what I expect .

 

Nihar ANihar A
Usually when batch apex is executed , there are multiple log files that are generated as the job is first queued and then executed. Make sure to check all the log files generated in dev console when you are running the job.
This was selected as the best answer
Ty WhitfieldTy Whitfield
OMG Nihar - that was it.  I didn't even think abou that.  I just assumed it would be in the log in the console.  I set up the debug logs through Set-up and now I see all of the logs.  Thanks