How to get SharePoint dll version using JavaScript quickly

If you are working on SharePoint apps development you will need to know the SharePoint dll version to put webparts in to the page. In webparts we need to provide the SharePoint dll version in the 

In this sinario you can use following service url and make a quick call and get the version of the SharePoint dll on Office 365 SharePoint Online as well as SharePoint Onprem.

/_vti_pvt/buildversion.cnf

SharePoint On Premise output
vti_encoding:SR|utf8-nl
vti_buildversion:SR|15.0.4737.1000

SharePoint Online Office 365 output as of 04/07/2017
vti_encoding:SR|utf8-nl
vti_buildversion:SR|16.0.6621.1204

Function for get the version no.
    getSharePointVersion: function () {
        var ver = null;
        $.ajax({
            url: "/_vti_pvt/buildversion.cnf",
            async: false,
        }).done(function (result) {
            var lines = result.trim().split('\n');
            if (lines.length == 2) {
                var versionProperty = lines[1].split('|');
                ver = (versionProperty.length == 2 ? versionProperty[1] : null);
            }
            else {
                ver = null;
            }
        });

        return ver;
    }

Hope this will help someone.

Comments

Popular posts from this blog

SharePoint App Only Registration Key Renewal script