<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Latest document version not being captured</title><link>https://community.appian.com/discussions/f/plug-ins/20031/latest-document-version-not-being-captured</link><description>Having an issue with document related Plugins such as Copy Document and PDF from Docx(with fonts) 
 To test the scenario, I created and uploaded a docx file to appian called &amp;quot;WordDocument&amp;quot;. In the body of the document, i input &amp;quot;Version #1&amp;quot; 
 I then uploaded</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Latest document version not being captured</title><link>https://community.appian.com/thread/78344?ContentTypeID=1</link><pubDate>Mon, 07 Dec 2020 22:23:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9dbb8f84-e91c-4164-8f2f-56a3713b5d95</guid><dc:creator>skyappian</dc:creator><description>&lt;p&gt;Thanks mike! Worked like a charm.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Latest document version not being captured</title><link>https://community.appian.com/thread/78342?ContentTypeID=1</link><pubDate>Mon, 07 Dec 2020 19:55:51 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c3bfc83a-e8d2-4729-94f1-8dfe95dd1c5e</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Hey aakash- hope things are going well for y&amp;#39;all.&lt;/p&gt;
&lt;p&gt;I had a similar issue when dealing with a custom plug-in that generates an excel file - i noticed eventually that it always gets the original version of an uploaded template and disregards subsequent new versions.&amp;nbsp; I believe this is a bug in the plug-in in question, and it sounds from your description like Content Tools might have a similar issue.&lt;/p&gt;
&lt;p&gt;Luckily I stumbled on the following code snippet which uses a bit of a brute-force approach to look up the document id for the latest version of a file with multiple versions (i think in the Appian FS, the updated version is given its own unique id, but the original ID essentially becomes a pointer to the new ID, which helps explain why certain functionality misses this and still uses the original referenced document).&lt;/p&gt;
&lt;p&gt;We have this as a utility expression rule i.e. `RULE_Utility_getLatestDocumentVersion`, with an input for Document and an optional input for RootFolder (which i think can usually be omitted).&lt;br /&gt;&lt;pre class="ui-code" data-mode="java"&gt;todocument(
  tointeger(
    index(
      findcontentbyattribute(
        searchAllContent: false(),
        contentType: &amp;quot;document&amp;quot;,
        attributeName: &amp;quot;name&amp;quot;,
        searchCriteria: document(ri!document, &amp;quot;name&amp;quot;),
        rootFolder: rule!RULE_General_replaceNull(
          ri!rootFolder,
          document(ri!document, &amp;quot;folderId&amp;quot;)
        )
      ),
      1,
      null()
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>