You need to sign in to do that
Don't have an account?
Chiyan
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');
}
}
}
}
write a test class for below trigger
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');
}
}
}
}
Greetings to you!
Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
Below code helps, if you have an Opportunity associated with Account, Thanks,
Govindaraj.S