Created
September 25, 2019 01:12
-
-
Save sakthivelsfdc/f21c5ee54ffe369481f738dac37e72e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger OpportunityDeleteTrigger on Opportunity ( before delete ) { | |
String name = [SELECT Name FROM Profile WHERE Id =:UserInfo.getProfileId()].Name; | |
if( name != 'System Administrator' ) { | |
if( Trigger.isBefore ) { | |
if( Trigger.isDelete ) { | |
for( Opportunity objOpportunity : Trigger.old ) { | |
if( objOpportunity.IsClosed == true ) { | |
objOpportunity.addError( 'This opportunity cannot be deleted becase it has been closed. Please contact Sales Operations.' ); | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment