+ Start a Discussion
sales@myvarmasales@myvarma 

trigger on account stop update on account number

trigger updateact on Account (before update) {
map<id,Account> oldmap=trigger.oldmap;
    
    for(account acc: trigger.new){
        if (acc.AccountNumber != oldmap.get(acc.id).AccountNumber)
        {
            acc.AccountNumber.addError(' Please contact Master Data to make this change.');
        }
    }
 
}




when i m trying to edit account number which is already created
it must through error
i m getting errors 
help me
Harshit Garg 6Harshit Garg 6

Hi Sales@myvarma,

Your trigger is working fine..Please tell me in which scenario you have tested.

I have tested like - In old account and edit the acount number field and at the time of saving it is giving error..which error you are showing in trigger

Thanks,
Harshit garg