1

Currently my scheduler calls all the records in the queue 'New Leads Queue' and it does every 10 mins interval and we are having issues with the API limit.

So we decided to make changes to the code such a way that it only calls the first 25 records in the queue(which should be sorted by newly created date). I know I can't expect someone to do my entire code if it involves lot of changes so any suggestions on how to achieve this would be great!.

Following is my Batch Apex,

global class scheduledInsideSalesCall implements Schedulable {
   global void execute(SchedulableContext SC) {
      String Query='Select Id,owner.name,Lead_Tier__c,Number_of_Seats__c,LeadSource,Campaign_Name__c from Lead where owner.name=\'New Leads Queue\'';
      ImmediateResponse insidesales = new ImmediateResponse(Query); 
      database.executebatch(insidesales,50);
   }
}
4

Your query should look like:

String Query='Select Id,owner.name,Lead_Tier__c,Number_of_Seats__c,LeadSource,Campaign_Name__c from Lead where owner.name=\'New Leads Queue\' ORDER BY CreatedDate DESC LIMIT 25';
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.