Skip to content

Instantly share code, notes, and snippets.

@prasannadeshpande
Created January 28, 2018 14:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save prasannadeshpande/7ad6f5e49c83ab5a84e628e1096c24f8 to your computer and use it in GitHub Desktop.
TriggerOnAttachment
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