Trigger to restrict attachment Size restriction in Salesforce

Trigger to restrict attachment Size restriction in Salesforce

Using trigger we can impose attachment Size in Salesforce before attaching it. Check the following trigger for reference.
 
Sample Trigger:

trigger AttachmentBIUTrigger on Attachment (before insert, before update) {

    for(Attachment att : trigger.new) {

        if(att.Body.size() > 3145728) {

            att.addError(‘Size cannot be greater than 3 MB’);

        }

    }

}

Leave a Reply