+ Start a Discussion
lohith mlohith m 

Batch Class

Hi I am new to salesforce, Here i have scenarios please help me...

1) I have two objects called  X and Y . Y is LookUp to X. Here X has different owner and Y has different owner . So I want a batch class so that I want to make the owner of Y=X.
2) I have a object called Employee so my requirement is to create another object that is exact replica of that object how can I do that with triggers.
Ajay K DubediAjay K Dubedi
Hi ...
    
global class BatchCreateOpportunity implements Database.batchable{
    global Database.QueryLocator start(Database.BatchableContext bc){
        String query = 'select id,name, (select id, lastname from contacts order by createddate asc ) from Account';
        return Database.getQueryLocator(query);
    }
     
    global void execute(Database.BatchableContext BC, List scope)
    {
        List accList = new  List();
         for(Account acc : scope )
     {  
          
         for(contact c : acc.contacts){
                acc.ownerid = c.ownerid
              accList.add(acc);
         }  
    }    
    update accList;
}
 global void finish(Database.BatchableContext BC)
    {
    }
}


 
if that code will help you then please mark it.