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.
Example:
ContentNote conNote = new ContentNote(
   Title = 'TheBlogReaders.com',
   Content = Blob.valueOf('TheBlogReaders.com')
 );
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.
Reference:
Import ‘Notes’ to the ‘ContentNote’ object with Data Loader – https://help.salesforce.com/articleView?id=000339316&language=en_US&type=1
Pro Tip: Boost Note-Taking with Enhanced Notes in Lightning Experience – https://admin.salesforce.com/pro-tip-boost-note-taking-enhanced-notes-lightning-experience

Written by 

I am Sakthivel Madesh, a certified Salesforce Advanced Developer & Administrator working on Salesforce Technology since 2011. I am currently working in Techforce Services as Sr. Salesforce Developer. I have worked on multiple technologies Like PHP, Java, Salesforce, I am very passionate about Salesforce and to earn 15x Salesforce Certification. I love Trailhead for learning Salesforce Skill and Become a Trailhead 5x Ranger too. I Love to Learn & Share my Salesforce knowledge to Salesforce Learners/Beginner using My Blog and Salesforce Community.

Leave a Reply