Detect SDK Capabilities by Checking CRM Server Version

19 April 2015
Daniel Cai

For all the latest and coolest features that we have illustrated in this blog series, they are only available in CRM Online 2015 Update 1 release. If you try to send any of the new SOAP messages to a server that has a lower version (including CRM 2015 on-premises), your code will break, as the feature is not supported. So we need a way to detect whether the server is capable of dealing with the new features.

The good news is, this is actually a relatively simple task, as CRM SDK has offered a RetrieveVersionRequest message which allows you to sniffer the server version. Let me show you how this can be done. 

using (var service = new OrganizationService(crmConnection))
    var request = new RetrieveVersionRequest();
    var response = (RetrieveVersionResponse)service.Execute(request);

    var version = new Version(response.Version);

    if (version >= new Version("7.1"))
        // Do the new way
        // Do the old way

The idea is, you use the RetrieveVersionRequest message to get the CRM server version, and check whether it is greater than 7.1 (which corresponds to CRM Online 2015 Update 1 release). If yes, you do things in the new way using the new SDK capabilities. Otherwise, you would use the old approach (if available).

This concludes my blog post series: New SDK capabilities - CRM Online 2015 Update 1 release. Hope this has helped.

Daniel Cai | KingswaySoft

Read the full New SDK Capabilities Blog Series: