Saturday, May 15, 2021

Sample Salesforce Batch Class

global class TaskShortURLBatch implements Database.Batchable<sobject>,Database.AllowsCallouts {

         //added code for reschedule link

  public  List<Id> t;

    public TaskShortURLBatch(List<Id> t){

        this.t=t;

    }

   global Database.QueryLocator start(Database.BatchableContext BC){

       //added code for reschedule link

       String query1='select id,OpenSMSPro__Reschedule_URL_Id__c,OpenSMSPro__Appointment_ID__c from task where id in:t';

      return Database.getQueryLocator(query1);

   }

   global void execute(Database.BatchableContext BC, List<sobject> scope){ 

       //added code for RescheduleLink

       List<task> tasklists = scope;

       for(Task taskobj : tasklists){

        String shortURL1=BitlyCalloutService.getRescheduleLink(taskObj);

           taskObj.OpenSMSPro__Reschedule_Link__c = shortUrl1;

       }  

           update tasklists;   

        //ended

   }

   global void finish(Database.BatchableContext BC){

   }

}

No comments:

Post a Comment

CSS Styling

Styling: 1. Inline Styling: < div style = "font-size: 2rem;font-weight: 400;" > Good Evening </ div > 2. Usi...