web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :

Retrieve the current CRM version

Guido Preite Profile Picture Guido Preite 54,086 Moderator
The CRM SDK DLLs can easily connect to different CRM versions, for example the CRM 2013 DLLs can be used also with CRM 2011/2015 environments.
Depending the version some messages (like the ExecuteMultipleRequest) are not available, the following function returns an enumerator with the current CRM version.

public enum CRMVersion
{
Unknown,
CRM2011,
CRM2011UR12PLUS,
CRM2013,
CRM2013SP1,
CRM2015
}

public CRMVersion GetCRMVersion(IOrganizationService service)
{
RetrieveVersionRequest versionRequest = new RetrieveVersionRequest();
RetrieveVersionResponse versionResponse = (RetrieveVersionResponse)service.Execute(versionRequest);

string version = versionResponse.Version;
if (version.StartsWith("5"))
{
try
{
int buildNumber = Convert.ToInt32(version.Substring(version.LastIndexOf(".") + 1));
if (buildNumber > 3000) { return CRMVersion.CRM2011UR12PLUS; }
}
catch { }
return CRMVersion.CRM2011;
}
if (version.StartsWith("6.0")) { return CRMVersion.CRM2013; }
if (version.StartsWith("6.1")) { return CRMVersion.CRM2013SP1; }
if (version.StartsWith("7")) { return CRMVersion.CRM2015; }
return CRMVersion.Unknown;
}

This was originally posted here.

Comments

*This post is locked for comments