Document is not the latest version

cancel
Showing results for 
Search instead for 
Did you mean: 
kkacperski
Active Member

Document is not the latest version

Jump to solution

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 Solution

Accepted Solutions
kkacperski
Active Member

Re: Document is not the latest version

Jump to solution

A change propretys only for the latest version 

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

View solution in original post

1 Reply
kkacperski
Active Member

Re: Document is not the latest version

Jump to solution

A change propretys only for the latest version 

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