How to capture ParentId in ContentNote Salesforce
Notes created with the enhanced note tool and this feature available from Winter’16. This object is available in API version 32.0 and later
While create a Notes in account, where to specify the Account Id in Content Notes. usually while insert any of the object like Attachment, we trying to specify the related object id under the ParentID field, but while create a notes to Account into ContentNotes, specify the Account Id to LinkedEntityId  field under the ContentDocumentLink Object.
ContentNote conNote = new ContentNote(
   Title = '',
   Content = Blob.valueOf('')
insert conNote; //Insert Content Note   

//create ContentDocumentLink  record 
ContentDocumentLink conDocLink = New ContentDocumentLink();
conDocLink.LinkedEntityId = '0066F00000qNVUv'; // Specify Account ID here
conDocLink.ContentDocumentId = conNote.Id;  //Content Note Id
conDocLink.shareType = 'V';
insert conDocLink;
Here ShareType is either V, C and I
V = Viewer permission. The user can explicitly view but not edit the shared file.
C = Collaborator permission. The user can explicitly view and edit the shared file.
I = Inferred permission. The user’s permission is determined by the related record. For shares with a library, this is defined by the permissions the user has in that library. Inferred permission on shares with libraries and file owners is available in API versions 21.0 and later. Inferred permission on shares with standard objects is available in API versions 36.0 and later.
Import ‘Notes’ to the ‘ContentNote’ object with Data Loader –
Pro Tip: Boost Note-Taking with Enhanced Notes in Lightning Experience –

Written by 

2x Salesforce MVP | Platform Champion | 18x Salesforce Certified | MuleSoft Certified | 8x Trailhead Ranger | TechForce Services | Sydney | Australia

Leave a Reply

Your email address will not be published. Required fields are marked *