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
Jay KanchanaJay Kanchana 

Duplicating content document

Hello!

We would look to duplicate a content in salesforce using apex. Is there a way to do that? I was hoping there will be a contentversion constructor that can receive the contentversion ID of a content and create a duplicate content. 
To provide the background information, We have a business process where we receive document from our applicants during one phase of the process. That document needs to be locked down when they enter to the next phase of the process. In the next phase of the process the will uploading a newer version of the document. If we use the same content from phase1 in to phase2, content they upload in phase2 will become newer version of the content rather than being its own content. Hence when the applicant enters from phase1 to phase2, the process that creates a phase2 record for the applicant should create a new content which is exact copy of the content they had provided. 
pconpcon
Looks like you just need to create a new ContentVersion [1] object via Apex either in your controller / trigger whenever it hits phase2.

[1] https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contentversion.htm
Jay KanchanaJay Kanchana
Hello!
What is teh syntax of the constructor? It appears that the FirstPublishLocationId  (work space ID) becomes read only once the document is created. 
I tried cloning content version and that did not work. 

May be I should access underlying content document and clone that instead of content version?
-Jay