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
PRADEEP YADAV 5PRADEEP YADAV 5 

if i only updated the account record old number to new number through trigger some error is coming

trigger AccountPhoneUpdate on Account (before Update) 
{
    Map<Id, Account>mapaccount = new Map<Id, Account>([Select Name, Phone From Account Where Id In : trigger.old]);
    
    List<Account>updatedaccount = new List<Account>();
    for(Account a : trigger.new)
    {
        Account oldphone =  mapaccount.get(a.Id);
        if(a.Phone != oldphone.Phone && a.phone !=Null)
        {
            updatedaccount.add(a);
        }
        
    }
    update updatedaccount;
        
    
}
David Zhu 🔥David Zhu 🔥
If (updatedaccount.size()>0){
update updatedaccount;
}
PRADEEP YADAV 5PRADEEP YADAV 5
Thanks 
But Some Error is Coming in that Question
abhishek singh 497abhishek singh 497
Hi Pradeep,
In a before update you don't need to explicitly call update on the records you want to modify. You're working on them before they go into the database, so you simply need to set the field values you want and that's it.
So no need to perform any DML in before context.

Thanks,
Abhishek Singh
PRADEEP YADAV 5PRADEEP YADAV 5
Thanks Abhishek
i will completed my developer part in the salesforce then i doing one project in the developer part . please suggesting me which type of project will be doing in the developer part