4

In Apex using a AfterInsert Trigger on ContentVersion (cv) object, the method cv.addError ('Custom message') is not working as expected.

Instead of showing the custom error message the error that is showing is just standard error and provide no information about the error.

trigger ContentVersionTrigger on ContentVersion (after insert) {
    for (ContentVersion cv : trigger.new) {
        System.debug(cv.Title+' : ' +cv.ContentSize);
        if(cv.ContentSize > 5242880){
            cv.addError('You can\'t upload files with size more than 5MB.');
        }
    }
}

There is a similar question in the Dev community (Trigger on ContentDocumentLink) but no answer.

5

0

You must log in to answer this question.

Browse other questions tagged .