cancel
Showing results for 
Search instead for 
Did you mean: 

Create a new document based on the content of a version of another document

PVanhoof
Champ on-the-rise
Champ on-the-rise

Hi,

What I want to do is read the versions of a given document, and for each version create a new document with the content of that version. I am using a rule that starts a javascript.

The new file is created and content copied, but when I click on the newly created document I get a 'Can not load PDF content'.

Mime type seems ok. Downloading the document and opening it also gives an error that content is unreadable. What is wrong?

 

var originalContent = documentVersion.node.content; // get content of the version

if (originalContent)
{
copiedNode.content = originalContent; // copiedNode is a new file created earlier
copiedNode.save();
}

 

 

 

1 REPLY 1

PVanhoof
Champ on-the-rise
Champ on-the-rise

The solution is

copiedNode.properties.content.write(documentVersion.getNode().properties.content);