+ Start a Discussion
srinivas pulipatisrinivas pulipati 

How to insert the phone number in particular contact record by using batch apex program?

please tell me the  answer

Thank you
ManojjenaManojjena
Hi srinivas ,
You want to insert or update phone number for a contact .
if you want to assign phone number of update phone number for a particular contact ,Assume contact name is  Srinivas.
Try with belwo code it will work .
 
global class ContactPhoneUpdateBatch implements Database.Batchable<sObject>{
    global Database.QueryLocator start(Database.BatchableContext BC){
        String query = 'SELECT Id,Name,Phone FROM Contact';
        return Database.getQueryLocator(query);
    }
    global void execute(Database.BatchableContext BC, List<Contact> scope){
         for(Contact con: scope){
             if(con.Name=='Srinivas'){
			   con.Phone=8880009993;
			 }            
         }
         update scope;
    }   
    global void finish(Database.BatchableContext BC){ }
}
Check below link for more detail about batch apex .
http://manojjena20.blogspot.in/2015/06/batch-apex-in-depth.html 
Let me know if it helps

Thanks
Manoj
 
srinivas pulipatisrinivas pulipati
But Contact number is not insert in perticular record


i Am write in  Execute Anonymus: Database.executeBatch(new BatchContactUpdateRecord());


but number is not inserted