+ 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​​​​​​​