In this article you will see how to get the major and minor version of the file in SharePoint 2010 using ECMAScript.IntroductionIn this article you will see how to get the major and minor version of the file in SharePoint 2010 using ECMAScript. I have a document library named "Shared Documents" which has the following document.I am going to get the major and minor version of the file.Steps Involved
var item; var list; var file;
function fileMajorandMinorVersion() { var clientContext = SP.ClientContext.get_current(); if (clientContext != undefined && clientContext != null) { var webSite = clientContext.get_web(); this.list = webSite.get_lists().getByTitle("Shared Documents"); this.item = list.getItemById(16); this.file = this.item.get_file();
clientContext.load(this.file); clientContext.executeQueryAsync(Function.createDelegate(this, this.OnLoadSuccess), Function.createDelegate(this, this.OnLoadFailed)); } }
function OnLoadSuccess(sender, args) { var version = "Major Version: " + this.file.get_majorVersion() + '\n' + "Minor Version: " + this.file.get_minorVersion(); alert(version) }
function OnLoadFailed(sender, args) { alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); }</script> <input id="btnFileMajorandMinorVersion" onclick="fileMajorandMinorVersion()" type="button" value="File Major and Minor Version"/>
Click on Ok.
In the ribbon interface click on Save & Close button.
In the content editor web part you can find a button named "File Major and Minor Version", click on that button.
An alert will pop up which displays the following.
Reference
SummaryThus in this article you have seen how to get the major and minor version of the file in SharePoint 2010 using ECMAScript.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: