retriveing the current CRM version using web api request in mscrm

///the complete code for using RetrieveVersion function, which can be used to get current CRM version:

function GetCRMVersion() {
    //get CRM URL
    var serverURL = Xrm.Page.context.getClientUrl();

    //write request for function 
    var req = new XMLHttpRequest();
    req.open("GET", serverURL + "/api/data/v8.0/RetrieveVersion()", true);
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.setRequestHeader("OData-MaxVersion", "4.0");
    req.setRequestHeader("OData-Version", "4.0");
    req.onreadystatechange = function() {
        if (this.readyState == 4 /* complete */ ) {
            req.onreadystatechange = null;
            if (this.status == 200)//check response is OK {
                var data = JSON.parse(this.response);
                alert("You are using Microsoft Dynamics CRM "+data.Version);
            } else {
                var error = JSON.parse(this.response).error;
                alert(error.message);
            }
        }
    };
    req.send();
}

Comments

Popular posts from this blog

Basic Plugin Code in D365 using C#

CURD (Create, Update, Retrieve and Delete) Operation in D365 using Power Shell Script

Meta Data Using WebApiRequest