How to work around the 100 callout limitation?



down voteaccepted
Create a batchable class, and do as many callouts as you need.
 The 100 callout limit applies only to a single transaction, but Batchable classes can create millions of transactions. 

You could do this:
global class Do2999Callouts implements Database.Batchable<Integer> {
    global Iterable<Integer> start(Database.BatchableContext context) {
        Integer[] values = new Integer[0];
        while(values.size() < 2999) values.add(values.size());
        return values;
    }
    global void execute(Database.BatchableContext context, Integer[] values) {
        // Do one callout for each integer in values
    }
    global void finish(Database.BatchableContext context) {
    }
}
You would call this code using:
Database.executeBatch(new Do2999Callouts(), 100);
Of course, this is only an arbitrary example. You could use smaller batch sizes, base them off of records, or do whatever else you need to. 

Comments

Popular posts from this blog

All about workflow rule , limitation and important points with example

Custom Setting in Salesforce

Action tags in VisualForce Salesforce