Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
trigger AttachmentTrigger on Attachment (before insert) {
set<String> setExtNotAllowed = new set<String> {'exe','dll'};
for (Attachment attachment {
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
You can’t perform that action at this time.