I have a two documents (a.pdf and b.pdf) in the Alfresco repository. I want to apply/upload b.pdf as a new version of a.pdf. Is there any way that I can do this using Javascript or a java code?
Thank you
I have a two documents (a.pdf and b.pdf) in the Alfresco repository. I want to apply/upload b.pdf as a new version of a.pdf. Is there any way that I can do this using Javascript or a java code?
Thank you
On
Create Document, Make it Versionable, Modify It Creates a document, makes it versionable, checks it out, modifies the content of the working copy, checks it in again and then repeats the process but checks in the document with a version history note and as a major version increment:
// create file, make it versionable
var doc = userhome.createFile('checkmeout.txt');
doc.addAspect('cm:versionable');
doc.content = 'original text';
// check it out and update content on the working copy
var workingCopy = doc.checkout();
workingCopy.content = 'updated text 1';
// check it in
doc = workingCopy.checkin();
// check it out again
workingCopy = doc.checkout();
workingCopy.content = 'updated text 2';
// check it in again, but with a version history note and as major version increment
doc = workingCopy.checkin('a history note', true);
You can take reference from below javascript api link https://hub.alfresco.com/t5/alfresco-content-services-hub/javascript-api-cookbook/ba-p/293260
There's a version service bean that can be used to apply versioning to documents (nodes) that can be used in a custom bean. Don't forget to inject the versionService in your service-context.xml btw
<property name="versionService" ref="VersionService"/>If I remember correctly you may have to enable a versionable aspect (cm:versionable) on the node in question. If this has already been enabled then there's also the ability to view the VersionHistory for the node.
Create 2nd version and copy over with the contents of node 2.