Created
January 28, 2018 14:32
-
-
Save prasannadeshpande/7ad6f5e49c83ab5a84e628e1096c24f8 to your computer and use it in GitHub Desktop.
TriggerOnAttachment
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 AttachmentTrigger on Attachment (before insert) { | |
set<String> setExtNotAllowed = new set<String> {'exe','dll'}; | |
for (Attachment attachment :Trigger.new) { | |
String strFilename = attachment.Name.toLowerCase(); | |
List<String> parts = strFilename.splitByCharacterType(); | |
if(setExtNotAllowed.Contains(parts[parts.size()-1])) { | |
attachment.addError('File with extension exe or dll could not be attached!!'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment