AnsweredAssumed Answered

Link to different version of a document

Question asked by s.loudiyi on Apr 20, 2016
Latest reply on Apr 22, 2016 by s.loudiyi

Hello people !

I have a librairy with some Excel Document (I talked about it in a precedent question). There's versioning activated for having the different version of the documents.

Now my company want to be able to link the document in a different list, AND, to be able to acces directly the version of the document when it was linked to the list. An exemple :

There a document with three version and a list with a link to that document. The list have three item, each who was made at different time, and when the document had a different version. The goal is to be able to have a link to the version of the document who correspond. Like that

En-tête 1En-tête 2En-tête 3
List item 1Document version 1link to document version 1  http://[siteName]/_vti_history/512/[listName]/[itemName]
List item 2Document version 2link to document version 2 http://[siteName]/_vti_history/1024/[listName]/[itemName]
List item 3Document version 3

link to document version 3 (most recent version) http://[siteName]/[listName]/[itemName]

I know that different version of a document is stored on http://[siteName]/_vti_history/[versionNumber*512]/[listName]/[itemName], but the problem is how to update the link when it is not the most recent version (whose link is http://[siteName]/[listName]/[itemName] ) anymore ? Like, let's say, a new version is created and add in the list :

En-tête 1En-tête 2En-tête 3
List item 1Document version 1link to document version 1  http://[siteName]/_vti_history/512/[listName]/[itemName]
List item 2Document version 2link to document version 2  http://[siteName]/_vti_history/1024/[listName]/[itemName]
List item 3Document version 3link to document version 3  (change and became) http://[siteName]/_vti_history/1536/[listName]/[itemName]
List item 4Document version 4link to document version 4 (new most recent version) http://[siteName]/[listName]/[itemName]

 

 

At first I was thinking about a Workflow which'll trigger when a new document version are created and who will update every link where the file version =/= the most recent version, but the workflow would not start. Plus, it seem I can't get the version number in integer (it get it in String, and I can't convert it), and because of that I can't calculate the version folder for the link. How can I get that ?

 

Finally, I had an other idea. Instead of directly give the link to the version, I was thinking of creating a button in the form (on view mode) with a javascript code which will check the version of the file on the form and the most recent version, and if they are different, redirect the user with a link with _vti_history/versionFolder, or if they are equal, redirect to the most recent version. The problem : I don't know javascript (never used it before), and while  I can try to learn the basics, I want to know how to use it with nintex.

Here's a pseudo code of the idea I had (of course the syntax are bad, I tried to make something with what I saw on the net, but it's for illustrate what I mean) :

 

var verRec = //The field of the most recent version of the file;

var ver = //The field of the actual version of the file;

var fileName = /The file name;

var fileFolderNumber = ver*512;

var linkAlt ="http://nameOfMySite/nameOfTheDocumentLibrary/"+fileName;

var link="http://nameOfMySite/_vti_history/"+fileFolderNumber+"/nameOfTheDocumentLibrary/"+fileName;

if verRec==ver{

     Windows.open(linkAlt);

}else{

     Windows.open(link);

}

I saw a solution here http://theressomethingaboutsharepoint.blogspot.fr/2011/09/direct-link-to-certain-version-of.html but SharePoint would delete the javascript information in the html code, and I don't know how to solve that.

 

tl;dr :

I'm searching for a solution to link differents version of a file in a document Library to a List on SharePoint. The idea I add for that are :

  1. Creating a workflow who update all link in the list to link to the version of the file. Problem, I can't trigger th workflow each time a new version of a document is created, and I haven't found how to get the file version number in an integer format
  2. Create a button for the item form on view mode with javascript code to redirect the user to the document with the version wished for. Problem : I don't know javascript yet. I can try to learn it but I don't know the syntax for Nintex Form.
  3. Try to use the solution here http://theressomethingaboutsharepoint.blogspot.fr/2011/09/direct-link-to-certain-version-of.html, but SharePoint would delete the javascript information in the html code, and I don't know how to solve that.

 

Well, that's it. If someone can help me, it would be cool ^^" Or if someone have an other, good solution to link different version of a document, it's good too ^^

 

Oh also, while I'm at it, I have an other problem. When I create a new file on the document Library with a Template I set, I can't choose a name for the title column (it is a problem to search the file with a lookup field). I create a workflow to add the name when an document is created and the title field is empty but it increment eh version, which I want to avoid to still be on 1.0 with new document, instead of 2.0. If anybody have a solution, I'll welcomed it.

 

Sorry for my bad English ^^"

Outcomes