Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to check which version of CRM I'm using with the Help of Javascript?

Posted on by Microsoft Employee

Hi,

I'm developing a code in which i need to know if the version i'm using is CRM 2011/13/15.

So anyone Help me out with some code.

*This post is locked for comments

  • Suggested answer
    Royal King Profile Picture
    Royal King 27,686 on at
    RE: How to check which version of CRM I'm using with the Help of Javascript?

    Here is the complete script to get the version of the CRM.Let me know if it doers not work..

    function onload_Form() {
    var xml = "" +
    "<s:Envelope xmlns:s=\"schemas.xmlsoap.org/.../envelope\"><s:Body><Execute xmlns=\"schemas.microsoft.com/.../Services\" xmlns:i=\"www.w3.org/.../XMLSchema-instance\">" +
    "<request i:type=\"b:RetrieveVersionRequest\" xmlns:a=\"schemas.microsoft.com/.../Contracts\" xmlns:b=\"schemas.microsoft.com/.../Contracts\">" +
    "<a:Parameters xmlns:c=\"schemas.datacontract.org/.../System.Collections.Generic\"/><a:RequestId i:nil=\"true\"/>" +
    "<a:RequestName>RetrieveVersion</a:RequestName></request></Execute></s:Body></s:Envelope>" +
    "";
    var xmlHttpRequest = new XMLHttpRequest();
    xmlHttpRequest.open("POST", Xrm.Page.context.getClientUrl() + "/XRMServices/2011/Organization.svc/web", false);
    xmlHttpRequest.setRequestHeader("SOAPAction", "schemas.microsoft.com/.../Execute");
    xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xmlHttpRequest.setRequestHeader("Accept", "application/xml, text/xml, */*");
    xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
    xmlHttpRequest.send(xml);
    var resultXml = xmlHttpRequest.responseText;
    if (window.DOMParser) {
    parser = new DOMParser();
    xmlDoc = parser.parseFromString(resultXml, "text/xml");
    }
    else // Internet Explorer
    {
    xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async = false;
    xmlDoc.loadXML(resultXml);
    }
    var crmVersion = xmlDoc.childNodes[0].childNodes[0].childNodes[0].childNodes[0].childNodes[1].childNodes[0].childNodes[1].childNodes[0].nodeValue;

    alert(crmVersion);
    }

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to check which version of CRM I'm using with the Help of Javascript?

    Dear Guido,

    var version = 2011;

    if (Xrm.Page.context.getIsAutoSaveEnabled !== undefined) { version = 2015; }

    else { if (Xrm.Page.ui.setFormNotification !== undefined) { version = 2013; } }

    Xrm.Page.context.getIsAutoSaveEnabled is not undefined in CRM2013 also

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to check which version of CRM I'm using with the Help of Javascript?

    hi Guido,

    Actually in my code,i was trying to get all the products which are active/Inactive using fetchXML.Now when I'm Testing My code on CRM 2015 i'm getting all the products

    But in CRM 2015 Product have 4 status Active,Draft,Retired and Under Revision where In Crm 2011/2013 there are ony two i.e. Active & Inactive.So what i want to do is to get the version of CRM and accordingly set filter on my fetchXml

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to check which version of CRM I'm using with the Help of Javascript?

    i don't think just to rename namespace is going to do any good with the error

  • Rajkumar Rajaraman Profile Picture
    Rajkumar Rajaraman 18,108 on at
    RE: How to check which version of CRM I'm using with the Help of Javascript?

    Use this,

    errorCallback(SDK.SOAPSamples._getError(req.responseXML));

    instead of

    errorCallback(SDK.SAMPLES._getError(req.responseXML));

    Refer this also:

    https://msdn.microsoft.com/en-in/library/gg594434.aspx

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to check which version of CRM I'm using with the Help of Javascript?

    4456.error.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans