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
bharath11rbharath11r 

APEX Batch

I have a webservice which will return me Any changes to Accounts happened in the last 7 days.

So basically I wrote a method which calls the webservice and parse the soap response and updates all the account records.

 

If i put this in batch I dont have any querylocator rows for my batch to pass onto Execute.For that i am returning a dummy row .

 

 global database.Querylocator start(Database.BatchableContext context){
            //Get all the Account Records whose docket numbers are not empty
            return Database.getQueryLocator([Select Id, Name From Account Limit 1]);
        }

         //Method to execute the batch
        global void execute(Database.BatchableContext context , List<sObject> scope)
        {
                    
 
              ErrorMessage = Carrier411Service.UpdateChangedCarriersBatch();
               
        }

 

For some reason its not even calling the UpdateChangedCarriesBatch. Am i missing anything..

 

How do i implement a batch where there is no querylocator. My webservice is giving me all the updated carriers.

 

 

Any help is appreciated.

 

Thanks,

Bharath

yo julioyo julio

in start method you can return a query locator or a list of sObject.

 

to make a callout from a batch you must uses: Database.AllowsCallouts in its declaration, so:

 

global class SearchAndReplace implements Database.Batchable<sObject>, 
   Database.AllowsCallouts{
}
bharath11rbharath11r

global  class BatchUpdateChangedCarriers implements
    Database.Batchable<SObject>,Database.AllowsCallOuts {

 

I am already doing that in my class. My question is I dont need database.QueryLocator because my batch gets the records to be updated from the webservice not from the batch.Hope I made myself clear.