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
kaustubh chandratrekaustubh chandratre 

whenever phone field updated in account then the name field should also get updated with name and phone number in account

PriyaPriya (Salesforce Developers) 

Hey Kautubh,

You have to write the Trigger on Account.

If you provide me with more detail, i can help you with the code. 

Regards,

Priya Ranjan

Rama Gaikwad 1Rama Gaikwad 1
Hi Kaustubh,

You can do it by the trigger.
Please, refer to the trigger code for your reference. Hope it will help you.
 
trigger updateAccountDetails on Account (before update) { 
// trigger before updation of the 
    List<Account> accList = new List<Account>(); 
// get list of all account which are upating 
        for(Account fetchAcc : Trigger.new) { 
// loop to handle bulk account record updation
            String sPhoneNum = String.valueOf(fetchAcc.Phone); 
// convert phone integer into string for further calculation
            if(!fetchAcc.Phone.isEmpty() && !fetchAcc.Name.contains(String.valueOf(sPhoneNum))) { 
// when phone is not empty and number is not added in name
            	fetchAcc.Name = fetchAcc.Name +'_'+ sPhoneNum; 
// update name in name_phoneNum format
        }
    }
}

Regards,
Rama Gaikwad