+ Start a Discussion
CBBsfdcCBBsfdc 

Write a Trigger to restrict Amount change on a WON Opportunity

NitishNitish
Hi CBB123456,

Please find the below trigger for your requirement.
trigger OpportunityTrigger on Opportunity (before update) {
    if(Trigger.isBefore && Trigger.isUpdate){
        for(Opportunity op:Trigger.new){
            if((Trigger.oldMap.get(op.id).Amount!=Trigger.newMap.get(op.Id).Amount) && op.StageName=='Closed Won'){
                op.addError('you cannot change Amount on Won stage');
            }
        }
    }
}
Thanks,
Nitish