<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Document is not the latest version in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/document-is-not-the-latest-version/m-p/139272#M37261</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;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.&lt;BR /&gt;When I try to move all versions and add the DELETED flag, I get an error with the "Document is not the latest version".&lt;/P&gt;&lt;P&gt;This error appears when I want to change properties of lower version of document.&lt;/P&gt;&lt;P&gt;How can I change properties for lower version?&lt;/P&gt;&lt;PRE&gt;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&amp;lt;String, Object&amp;gt; updateProperties = new HashMap&amp;lt;&amp;gt;();
            updateProperties.put(Config.PROP_NAME_STATUS, Config.CONST_DOK_USUNIETY);
            doc.updateProperties(updateProperties);&lt;/PRE&gt;&lt;P&gt;This erro appears when run&amp;nbsp;doc.updateProperties(updateProperties)&lt;/P&gt;</description>
    <pubDate>Tue, 21 Feb 2023 13:22:15 GMT</pubDate>
    <dc:creator>kkacperski</dc:creator>
    <dc:date>2023-02-21T13:22:15Z</dc:date>
    <item>
      <title>Document is not the latest version</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/document-is-not-the-latest-version/m-p/139272#M37261</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;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.&lt;BR /&gt;When I try to move all versions and add the DELETED flag, I get an error with the "Document is not the latest version".&lt;/P&gt;&lt;P&gt;This error appears when I want to change properties of lower version of document.&lt;/P&gt;&lt;P&gt;How can I change properties for lower version?&lt;/P&gt;&lt;PRE&gt;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&amp;lt;String, Object&amp;gt; updateProperties = new HashMap&amp;lt;&amp;gt;();
            updateProperties.put(Config.PROP_NAME_STATUS, Config.CONST_DOK_USUNIETY);
            doc.updateProperties(updateProperties);&lt;/PRE&gt;&lt;P&gt;This erro appears when run&amp;nbsp;doc.updateProperties(updateProperties)&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 13:22:15 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/document-is-not-the-latest-version/m-p/139272#M37261</guid>
      <dc:creator>kkacperski</dc:creator>
      <dc:date>2023-02-21T13:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: Document is not the latest version</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/document-is-not-the-latest-version/m-p/139273#M37262</link>
      <description>&lt;DIV&gt;&lt;P&gt;A change propretys only for the latest version&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;for &lt;/SPAN&gt;(Document version : doc.getAllVersions()) {&lt;BR /&gt;    &lt;SPAN&gt;if&lt;/SPAN&gt;(Boolean.&lt;SPAN&gt;TRUE&lt;/SPAN&gt;.equals(version.isLatestVersion())) {&lt;BR /&gt;        version.updateProperties(updateProperties)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;    } &lt;BR /&gt;}&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 27 Feb 2023 06:05:26 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/document-is-not-the-latest-version/m-p/139273#M37262</guid>
      <dc:creator>kkacperski</dc:creator>
      <dc:date>2023-02-27T06:05:26Z</dc:date>
    </item>
  </channel>
</rss>

