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
manav_mnvmanav_mnv 

I want to create a scheduler in Apex, in which i need to make 3 callouts. Can anybody please help me how to achieve this. Thanks

global class TourSyncBatch implements Database.Batchable<sObject>, Database.AllowsCallouts {
    
    public static string invokeUrl{get; set;}
    public static Map<String, Service_Endpoints__c> services {get; set;}
    
    public Database.QueryLocator start(Database.BatchableContext bc){
        //first callout to just invoke external service
        services = Service_Endpoints__c.getAll();
        
        invokeUrl = services.get('RefreshComms').Endpoint_URL__c;
        
         if(!test.isRunningTest())
        {
            // Invoke the URL
            HTTPWebCalloutUtil.HTTPWebCalloutGetRequest(invokeUrl);
        }
        
        return Database.getQueryLocator('select id, Tour_Reference__c, TourCreationStatus__c from Tour_Shell__c');
    }
    
    public void execute(Database.BatchableContext BC, List<Tour_Shell__c> Tourshell){
        // need to invoke two services here, on basis of some condition, how to achive that
        
    }
    
    public void finish(Database.BatchableContext info){
        
    }

}

Please help !!
Thanks in advance.

Regards,
Manav
Akhil ReddyAkhil Reddy
1. Invike callouts in execute method instead of start method.
2. please provide more details on what you are trying to invoke that would helpus to help u
 
manav_mnvmanav_mnv
HI Akhil,

ACtually the scenario is, I will make the first callout to ESB, that will in return give me list of Failed records which is unable to sync in SF.
They will return single parameter(Tour number) in json format.
So after that by using that Tour numbers(provided by ESB), i will make another callout to sync that tours.

Note: Everything is done by ESB, I just need to invoke the external services.

IN my code, I am using custom setting to invoke the url, that is already built.
Just need help in Batch class and Scheduler.

Thanks.