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
Suresh suri kSuresh suri k 

How show the error while chaning accont rating through trigger?

@anilbathula@@anilbathula@
Hi Suresh,

try this code:
trigger erroronrating on Account( before update) {
    for (Account acc: Trigger.new){
         if(acc.rating!=Trigger.oldMap.get(acc.Id).rating) {
                     acc.addError ('You cant change this value');
        }
    }
}

Thanks
Anil.B​​​​​​​