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)
Solved! Go to Solution.
A change propretys only for the latest version
for (Document version : doc.getAllVersions()) {
if(Boolean.TRUE.equals(version.isLatestVersion())) {
version.updateProperties(updateProperties);
}
}
A change propretys only for the latest version
for (Document version : doc.getAllVersions()) {
if(Boolean.TRUE.equals(version.isLatestVersion())) {
version.updateProperties(updateProperties);
}
}
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.