1

I have created a batch class to make callout from third party and get record and then save it in the salesforce.

Here is the sample of the code of my start method

public Database.QueryLocator start(Database.BatchableContext bc) {
  totalExecution = subdomainList.size(); 
  String query = 'select id FROM Account limit '+totalExecution ;
  return Database.getQueryLocator(query); 

}

this start will create scope for execute method.It work fine if my org have contain any record.But it failed when the org have no record. Is there any way to create scope on the basics of the integer value which i get on this(totalExecution) variable.

1 Answer 1

4

How about using an Iterable

public with sharing class SimpleBatchApex implements Database.Batchable<Integer> {

    public Iterable<Integer> start(Database.BatchableContext BC) {
        return new List<Integer> {1};
    }

    public void execute(Database.BatchableContext info, List<String> strings) {
        // Do something
    }

    public void finish(Database.BatchableContext info) {}
}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .