• German Mejias 7
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
In Apex using a AfterInsert Trigger over ContentDocumentLink (cdl) object, the method cdl.addError ('Custom message') is not working as expected. 
According to standard documentation https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contentdocumentlink.htm using a cdl.addError ('Custom message') should show a custom message error to the user (Standard lightning component Notes)
This is not the case. Instead the error that is showing is just standard error that provide no information to the user.
trigger cdlTrigger on ContentDocumentLink (after insert) {
    for (ContentDocumentLink cdl : trigger.new) {
        if (!CDLHelper.isSharingAllowed(cdl)) {
            cdl.addError('Sorry, you cannot share this file.');
        }
    }
}

public class CDLHelper {
    public static boolean isSharingAllowed(ContentDocumentLink cdl) {
       return false;
    }

}