+ Start a Discussion
Siddhartha GantediSiddhartha Gantedi 

Update contact phone with account phone

Hello guys, I am new to Salesforce, I just wanted to know in how many ways can I update contact phone number with account phone number whenever the contact is created.
Raj VakatiRaj Vakati
1. Workflow
2.Process Builder 
3. Apex Triggers 
4.Using FLows 
Ajay K DubediAjay K Dubedi
Hi Siddhartha,

Here are some ways to update the contact field with Account Field.
1). Using Workflow Rule, as shown below:


User-added image

2). Using Apex Code.

3). Using Process Builder.

4). Using Apex Trigger:

Trigger UpdateContactPhone on Contact(before insert,before update){    
    if(trigger.isBefore &&(trigger.isInsert || trigger.isUpdate))


public with sharing class UpdateContactPhoneHandler{
    public static void updateCon(List<Contact> lstContact){
        Set<Id> stAccId = new Set<Id>();
        for(Contact con : lstContact){
        List<Account> lstAccount = new List<Account>();
        lstAccount = [SELECT Id,Name,Phone FROM Account Where Id IN:stAccId];
        System.debug('List of Account:::::::::::::::'+ lstAccount);
        map<Id,Account> mapOfAcc = new map<Id,Account>(lstAccount);
        System.debug('map of Account:::::::::::::::'+ mapOfAcc);
        for(Contact objCon : lstContact){
            objCon.Phone = mapOfAcc.get(objCon.AccountId).Phone;
I hope it will help you.
Please select this as Best Answer so that other's also get help from this.
Thank You
Ajay Dubedi