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
yogendra Aragula 8yogendra Aragula 8 

using multiple objects on the same batch apex

HI ,

I want to use multiple objects on the same batch apex. I trying to Automate post-refreshment activities using sandboxpostcopy interface. The code is working fine to two activities, expect masking contact email id's  

global class TestSOSLBatch implements Database.Batchable<sObject> {
    global Database.QueryLocator start(Database.BatchableContext BC) {
        String query = 'SELECT Id,NotificationToEmail__c FROM SupportRequest_Routing_Rules__c';
        return Database.getQueryLocator(query);
       return Database.getQueryLocator([SELECT Email FROM Contact WHERE Email != '']);
    }
    global void execute(Database.BatchableContext BC, list<SupportRequest_Routing_Rules__c> reference){
        List<SupportRequest_Routing_Rules__c> asdf = new List<SupportRequest_Routing_Rules__c>();
        for(SupportRequest_Routing_Rules__c abc : reference){
            if(abc.NotificationToEmail__c != null){
                List<String> emailList = new List<String>();
                 system.debug('Log'+abc.NotificationToEmail__c);
                for(String s :abc.NotificationToEmail__c.split(';'))
                {
                    emailList.add(s);
                    system.debug(emailList);
                }
                list<string> templist = new list<string>();
                for(string s : emailList)
                {
                 templist.addall(s.split(','));   
                 system.debug(templist);                        
                    
                }
                string st ='';
                for( string s:templist )
                {
                    
                    
                    system.debug(st);
                    st = st + s + '.RMBOX' + ',';
                    system.debug(st);
                }
                    
                    
                abc.NotificationToEmail__c = st;
                asdf.add(abc);
            }
        }
        if(!asdf.isEmpty()){
            Update asdf;
        }
        for(CronTrigger ct : [SELECT id FROM CronTrigger where State = 'WAITING']){
            System.abortJob(ct.Id);
        }
        
        List<contact> scope = new list<contact>();
                 for(Contact c : scope)
         {
             c.Email = c.Email + '.Rambox';            
         }
         update scope;

    }
    global void finish(Database.BatchableContext BC) {
    }