1

How can I access the link to a previous version of a document in a library and assign that value to the new version of the document?

eg. Version 2 has been submitted and I want a link to the pervious version (1) attached to that document.

In addition to this, currently when the document is generated via a 3rd party it creates two versions, how can I delete the first of the two versions?

  • You can see the previous version of the document by going into version history of the file and right click on the file name of a specific version and select copy link address, but I was not able to open the older version of the file in owa. – sekhar Jul 30 '15 at 18:30
  • so as far as you are aware there is no way to access the versioning other than the number and by manually going into the record? – matt Jul 31 '15 at 15:22
  • Hope the code below helps you – sekhar Jul 31 '15 at 16:00
0

Here is the sample code I wrote in my project.

var ctx = SP.ClientContext.get_current();
var list = ctx.get_web().get_lists().getByTitle('Output-Files');
var file = list.getItemById(484).get_file()
var versions = file.get_versions();
ctx.load(versions);
ctx.executeQueryAsync(function(){
    var enumer = versions.getEnumerator();
    while(enumer.moveNext()){
        var currentItem = enumer.get_current();
        console.log(currentItem.get_url())
    }
},function(s,a){console.error(a.get_messgae())})

this is the url it displayed

_vti_history/512/OutputFiles/filename.docx

you can download the file, but cannot open in OWA

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.