How to create ContentNote and Link it to records in Salesforce?

How to create ContentNote and Link it to records in Salesforce?

ContentNote entity should be used to create Notes. ContentDocumentLink entity should be used to link it to the records.

Sample Code:

ContentNote objCN = new ContentNote();
objCN.Title = 'Test';
objCN.Content = Blob.valueOf( 'Testing Content' );
insert objCN;

ContentDocumentLink objCDL = new ContentDocumentLink();
objCDL.ContentDocumentId = objCN.Id;
objCDL.LinkedEntityId = '0018c00002H4wSIAAZ';//Hard coded account Id
insert objCDL;

Output:

Create ContentNote and Link it to r...
Create ContentNote and Link it to records in Salesforce

Leave a Reply