Skip to main content
Hello

 

I'm trying to complete chalenge in this trailhead (https://trailhead.salesforce.com/content/learn/modules/asynchronous_apex/async_apex_batch

). Looks like I have to use QueryLocator in start method of my batchable class. I can't do it with Querylocator. I have completed it with use of Iterable, but it's not accepted, an error occures:

The Apex class doesn't use a QueryLocator in the start method. Make sure you use a QueryLocator in the start method to collect all Lead records in the org.

When I open Batchable interface, there is:

global interface /*Database.*/Batchable

{

void execute(Database.BatchableContext param1, List<Object> param2);

void finish(Database.BatchableContext param1);

Iterable start(Database.BatchableContext param1);

}

 

start method is marked as Iterable. So it looks that I can't use Querylocator.

 

I wonder:

1) Why I can't use Querylocator? I mean, was it deprecated or what?

 

2) If there is no way to use Querylocator nowadays, how can we report to Trailhead that the challenge is a bit out-of-date?
3 réponses
  1. 15 juin 2021, 06:42
    I've found solution. It was easy.

     

    In my previous code I used interfase Database.Batchable<Lead>

     

    When I changed it to Database.Batchable<SObject> my method start can now work with Database.QueryLocator.
0/9000