Hi Everyone,
In this post, we will see how we can insert the Content Document or Content Version in Apex Test class.
Content Document: – Represents a document that has been uploaded to a library in Salesforce CRM Content or Salesforce Files.
Content Version: – Represents a specific version of a document in Salesforce CRM Content or Salesforce Files. One Content Document can have multiple content versions.
Content Document Link:- Represents the link between a Salesforce CRM Content document or Salesforce file and where it’s shared. A file can be shared with other users, groups, records, and Salesforce CRM Content libraries.
Here is the code for the test class.
ContentVersion – Contains the complete information about the Content Document. Which have the following field.
- Title – The title of a document.
- PathOnClient – The complete path of the document. One of the fields that determine the FileType.
- VersionData – The content of the file/document.
- Origin – The source of the content version. Valid values are:
- C—A content document from the user’s personal library. The label is Content. The FirstPublishLocationId must be the user’s ID. If FirstPublishLocationId is left blank, it defaults to the user’s ID.
- H—Salesforce files from the user’s My Files. The label is Chatter.
References
- https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contentversion.htm
- https://testwebgrantha.xyz/sfdc/how-to-preview-files-in-lightning-community-using-lwc/
- https://testwebgrantha.xyz/sfdc/how-to-download-files-from-lightning-community-using-lwc/
Thanks for reading 🙂
#HappyReading #DeveloperGeeks #AskPanther #SFDCPanther
[…] If you want to know how to insert a Content Document using Apex. Check here. […]
[…] If you want to know how to insert a Content Document using Apex. Check here. […]