cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Link to different version of a document

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 ^^"

Tags (1)
Reply
13 Replies
Workflow Hero

Re: Link to different version of a document

Is the document an attachment or is it a hyperlink column?

Thanks

Jan

Accept as Solution Reply
Not applicable

Re: Link to different version of a document

The documents is in a Document Librairy in an other place on the site.In the current list it is a link to that document, so yeah, either an hypertext link or a multiline text field.

Accept as Solution Reply
Workflow Hero

Re: Link to different version of a document

The simplest way to do this would be to use SharePoint's client side rendering, some examples are here Office Client-side rendering (JS Link) code samples in JavaScript

It is all JavaScript though so if you get stuck please let me know?

Jan

Accept as Solution Reply
Not applicable

Re: Link to different version of a document

Yeah, I heard about this side of SharePoint, but I had not really try it yet. I'll see what your link said

But for now, I am currently reading some lesson about javascript. It seem really usefull. I'll let you know later if I'm stuck

Accept as Solution Reply
Not applicable

Re: Link to different version of a document

So, I tried to make a button with javascript code to redirect to the document. But I'm stuck at getting the value of field. Here's my code (like I said before, I'm new to javascript ^^")

var verAct = NWF$('#' + verDoc).val();

var ver=NWF$('#' + verFic).val();

var verEx=parseInt(ver);

var fileName=NWF$('#' + fileNameForm).val();

var fileFolderNumber=ver*512;

var linkAlt= "http://siteName/documentLibraryName/"+fileName;

var linkCur= "http://siteName/_vti_history/"+fileFolderNumber+"/documentLibraryName/"+fileName;

console.log(fileName+","+verAct+","+ver+","+fileFolderNumber+","+linkAlt+","+linkCur);

if (verAct==verEx){

window.open(linkAlt);

}else{

window.open(linkCur);

}

The console.log give me "undefined,undefined,undefined,NaN,http://siteName/documentLibraryName/undefined,http://siteName/_vti_history/NaN/documentLibraryName/undefined"

Here's the form :

issue.PNG

verDoc -->The second lookup (who is filter by the value of the first one)

verfic -->Well, VerFic

fileNameForm --> esf

How can I get the value on the field ?

Accept as Solution Reply
Workflow Hero

Re: Link to different version of a document

Are you trying to do this using jslink (client side rendering) or is it a button on a form?

Accept as Solution Reply
Not applicable

Re: Link to different version of a document

It is a button in a form (I edited my post, i submit it by accident without completed it ^^")

Accept as Solution Reply
Workflow Hero

Re: Link to different version of a document

Not sure I understand what you've got in the dropdowns, are they document names?

Accept as Solution Reply
Not applicable

Re: Link to different version of a document

This is a lookup to the document Library. The first one show the title of the document, and the second the version. I don't think that's right, but i haven't yet found a mean to get the document name/title and the version number (I can show it with a list view but I don't know how to extract it from there).

0 Kudos
Accept as Solution Reply