function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Joseph PescatelloJoseph Pescatello 

Apex code considerations when changing from Salesforce Notes and Attachments to Notes and Files

We're exploring what it will take to convert to the new Notes and Files model. We currently have a fair amount of Apex code in controllers, triggers, pages, etc. that either retrieves or stores Notes and Atatchments.

Aside form the work of converting the existing Notes and Attachments, we're trying to determine the development effort required to change our APex code go handle the new model. Can anyone recommend any best-practices or point me at any documentation on how we might approach this task?

Thank you
E Jayaraman IyerE Jayaraman Iyer
Hi Joseph,

I think it will be much easier if you create a utility method for inserting the files. All you need to do is to pass the file and the parentId from wherever you have attached a file and the Utility method will insert record into Files. Doing this will also reduce your efforts in future if anything changes.

Let me know if any further information is needed.

Thanks
Joseph PescatelloJoseph Pescatello
Thank you for the reply, but let me re-phrase the question:
We currently only have to write a single object when creating Attachments (Attachment ) and we just have to query that one object when reading them. Same with Notes. But in the enhanced Notes and Files model, there are multiple objects related to Files (shown below). What I'm looking for is documentation on the objects that I need to consider when writing a new FIle or retrieving a File. 

ContentAsset
ContentBody
ContentDistribution
ContentDistributionView
ContentDocument
ContentDocumentHistory
ContentDocumentLink
ContentDocumentListViewMapping
ContentDocumentSubscription
ContentFolder
ContentFolderItem
ContentFolderLink
ContentFolderMember
ContentHubItem
ContentHubRepository
ContentNote
ContentNotification
ContentTagSubscription
ContentUserSubscription
ContentVersion
ContentVersionComment
ContentVersionHistory
ContentVersionRating
ContentWorkspace
ContentWorkspaceDoc
ContentWorkspaceMember
ContentWorkspacePermission
ContentWorkspaceSubscription