In any application, we need to add documents to our requests, and in some cases, it is interesting to manage versions of these documents. This is possible when using SharePoint to store documents. This article will focus on manipulating versions of a document in a SharePoint library.

K2 allow using SmartObjects, to manipulate the versions of a document with the method

Get Version

(detail of a specific version of a document) and

Get Versions

(list all the versions of a document):

Manipulate different versions of a document stored in SharePoint in a K2 form

But K2 does not return a link to consult a specific version. We must call the web service

_vti_history

:

https: // [monURLSharePoint] /_vti_history/1024/DemoVersion/MonFolder/MonDocument.xlsx

This link is composed of:

  • The URL of the SharePoint site where the file is stored
  • The name of the document (
    MyDocument.xlsx

    )

  • The folder name where this document is stored (
    MyFolder

    )

  • The name of the library (
    DemoVersion

    )

  • A version ID (1024)

This ID is the conversion of the version number into base 512 🤔

Are you lost? Do not panic, the way to get this ID is simple:

Version ID = ([Major Version] * 512) + [Minor Version]

🧐 For exemple, version 3.2 of a document, will give as version ID: (3 * 512) + 2 = 1538

In your forms, simply generate this URL to access all versions of a document stored in SharePoint.

🧐 Tip: A

Restore Version

method may be useful for restoring a previous version of a document.

It’s your turn 😉

Leave a Reply

Your email address will not be published. Required fields are marked *