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
Carmen NeelyCarmen Neely 

How to mass move phone numbers from the work phone field to the mobile phone field?

How can I mass move phone numbers from the work phone field to the mobile phone field on a contact?
Abdul KhatriAbdul Khatri
You can do it in following ways depend what is your requirements
  1. DataLoader for one time update
  2. Following Batch Job, can be schedule to run
global class ContactPhoneMoveBatch implements Database.Batchable<sObject>{

   global final String Query;

   global ContactPhoneMoveBatch (){

    query = 'Select MobilePhone From Contact Where Phone != null And Phone != MobilePhone';

   }

   global Database.QueryLocator start(Database.BatchableContext BC){
      return Database.getQueryLocator(query);
   }

   global void execute(Database.BatchableContext BC, List<Contact> scope){
     for(Contact s : scope){
         s.MobilePhone = s.Phone; 
     }
     update scope;
   }

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

 
Carmen NeelyCarmen Neely
Thanks Abdul,

Is DataLoader an app I need to install?  If so, please share the Appexchange Link.
Abdul KhatriAbdul Khatri
Dataloader you can find under you Salesforce Org

Go to Setup
Under Quick Find / Search, type Data Loader
Carmen NeelyCarmen Neely
Thanks!  I think I get it.  Using Data Loader, I can:
  1. download my contacts as csv
  2. Copy and past the data
  3. upload it back into salesforce and it will update each record
Is this correct?  (As you can tell, I am new to these type of Salesforce actions.)
Gururaj BGururaj B
If you want this to be done one time you can execute this from Anonymous window or if you want this to be a scheduled batch job use the below code in a scheduled job. If it helped please mark as best answer.(You might need to change the field and object name on this code)
list<account> conlist = new list<contact>();
list<account> updateConlist = new list<contact>();
conlist=[select id,workphone,mobilephone from contact];
for(contact c:conlist)
{
c.workPhone=c.mobilephone;
updateConlist.add(c);
}
update updateConlist;

 
Abdul KhatriAbdul Khatri
Yes that is correct

you can download the contacts using my SOQL in the above code. Replace the MobilePhone to Phone.

After download the contact as csv. Change the column name Phone to MobilePhone and then using Data Loader update the contact