How to restrict users to update closed Opportunity?

Sample Trigger:

trigger OpportunityTrigger on Opportunity (before update) {
    for(Opportunity oppty : trigger.new) {
        if(trigger.oldMap.get(oppty.Id).StageName == 'Closed Won') {
            oppty.addError('Closed Opportunity cannot be updated');
        }
    }
}

Cheers!!!

No comments:

Post a Comment