Skip to content

Instantly share code, notes, and snippets.

@ryanguest
Created June 25, 2015 20:22
Show Gist options
  • Save ryanguest/65a4ea1152455716fb12 to your computer and use it in GitHub Desktop.
Save ryanguest/65a4ea1152455716fb12 to your computer and use it in GitHub Desktop.
ContentDocumentLink example from Apex
@davidrobertslogicom
Copy link

I tried this with adding a note to an event but get the error
"First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Document]: [Document]".

My code is:

    ContentNote cn = new ContentNote();
    cn.content=Blob.valueOf(noteforevent.escapeHTML4());
    cn.title='Note on event';
    
    ContentDocumentLink link = new ContentDocumentLink();
    link.LinkedEntityId = eventID;  //eventId is coming in with valid content!!
    link.ContentDocumentId = cn.id;
    link.ShareType = 'C';
    link.Visibility = 'AllUsers';
    insert link;

@mhamzas
Copy link

mhamzas commented Jun 12, 2019

Enabling this triggers gives error to community user while creating Notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment