I want to show error msg whenever notes get created without attaching to any records. As trigger on ContentNote is not available I've written Trigger on ContentDocumentLink, but I am not able to show error msg on New Note screen.


trigger ContentDocumentLinkTrigger on ContentDocumentLink (after insert) {
    String strLinkedEntityId;
    for(ContentDocumentLink nt : trigger.New){
        strLinkedEntityId = nt.LinkedEntityId+'';
            //nt.ContentDocumentId.addError('Notes can not be save as private, attach it to any record');
  • Try hooking onto the ContentDocument object to trigger your validation logic - if there are no links to other records, no ContentDocumentLinks will be created hence your logic never fires. That said, I havent been able to hook any error messages into the content note UI either! Good luck. – CloudHugger Feb 16 '18 at 5:43
  • I am not clear about the relationship between ContentDocument & ContentNote objects, I followed the following salesforce developer guide doc which is also not showing any relationship between mentioned object. would u pls help me in understanding how ContentDocument is related to ContentNote? developer.salesforce.com/docs/atlas.en-us.api.meta/api/… – Keval Suchak Feb 26 '18 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.