cancel
Showing results for 
Search instead for 
Did you mean: 

Document is not the latest version

kkacperski
Champ on-the-rise
Champ on-the-rise

Hi,

I have a question about deleting (moving) a document with multiple versions to another folder. I have a case where a document has two versions of nodeId;1.0 and nodeId;2.0. As part of anonymization, I want to move all versions of this document to a different folder.
When I try to move all versions and add the DELETED flag, I get an error with the "Document is not the latest version".

This error appears when I want to change properties of lower version of document.

How can I change properties for lower version?

String targetFolderPath = getFolderPathForAnonymize(order.getReportId(), order.getId());

Folder folder = getFolder(targetFolderPath);
       if (folder == null) {
            folder = createFolderTree(targetFolderPath);
        }

        Session session = getSession();

        Document doc = (Document) session.getLatestDocumentVersion(session.createObjectId(nodeId));

doc.addToFolder(folder, true);

            Map<String, Object> updateProperties = new HashMap<>();
            updateProperties.put(Config.PROP_NAME_STATUS, Config.CONST_DOK_USUNIETY);
            doc.updateProperties(updateProperties);

This erro appears when run doc.updateProperties(updateProperties)

1 ACCEPTED ANSWER

kkacperski
Champ on-the-rise
Champ on-the-rise

A change propretys only for the latest version 

for (Document version : doc.getAllVersions()) {
if(Boolean.TRUE.equals(version.isLatestVersion())) {
version.updateProperties(updateProperties);
}
}

View answer in original post

1 REPLY 1

kkacperski
Champ on-the-rise
Champ on-the-rise

A change propretys only for the latest version 

for (Document version : doc.getAllVersions()) {
if(Boolean.TRUE.equals(version.isLatestVersion())) {
version.updateProperties(updateProperties);
}
}