December 8, 2014

Retrieve the current CRM version

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;
}

December 3, 2014

Browser compatibility & Dynamics CRM: a complicated marriage

The introduction of browser compatibility in Dynamics CRM (launched with UR12 for CRM 2011) was a big step for everybody using the platform, sadly this important change wasn't painless.
Several CRM implementations were done considering that Internet Explorer was the only compatible browser and this was quite the standard until CRM 4.0. With CRM 2011 Microsoft provided JavaScript supported methods (the Xrm namespace) to interact with Dynamics CRM in order to avoid DOM Manipulation.

Dynamics CRM developers struggle everyday between top-notch requirements and the limits of supported customizations, an endless fight without a definitive winner.

From some months a new variable must be considered: the browser used and its version. I already wrote about the argument (The browser compatibility cake is a lie) but new issues surfaced with the latest version of Google Chrome (V39) and a small recap regarding the browser compatibility can be useful.

Fact number 1: The supported browsers are Internet Explorer, Firefox, Google Chrome, Safari.
Not all OS are supported, for example Firefox and Google Chrome are not supported on Mac OSX, so it's necessary to check the compatibility lists.

Fact number 2: Google Chrome is the browser that caused most of the issues.
It's started with V37 with the removal of the showModalDialog method (fix link) and continued in V38 with the partial introduction of ES6 support (details link). V39 has a window.close error connected to the showModalDialog function (Chromium issue), where the popups (like a solution import) don't close by themselves after they completed the job.

Fact number 3: showModalDialog will work only until 30 April 2015.
The EnableDeprecatedWebPlatformFeatures setting states clearly that is until the end of next April. Less than 5 months for this temporary solution. Maybe the HTML5 tag <dialog> will be used?

Fact number 4: Google doesn't provide an archive of Google Chrome releases.
You want to install Google Chrome V36? You need to find the offline setup somewhere else. Remember that installing an older browser version is not suggested (security reasons).

Personally I don't like the phrase "Internet Explorer is the preferred browser for Dynamics CRM" that sometimes I read in some forums, because Microsoft invested time and resources to provide the browser compatibility for Dynamics CRM, efforts vanished for the most part by an "aggressive" update policy of Google Chrome.
Keep informed your users about the browser compatibility status and guide them in the choice of the browser used for Dynamics CRM.

November 26, 2014

CRM 2015 Report Extension and Visual Studio 2012

With the release of Dynamics CRM 2015, Microsoft made available the related tools including the new Report Authoring Extension (the download link is listed under my Resources page).

The Report Extension (required to build FetchXML reports) is now compatible with Visual Studio 2012.
SQL Server Data Tools - Business Intelligence for Visual Studio 2012 must be installed, together with .NET Framework 4.5.2:



Because I had in my machine the CRM 2013 Report Extension, the setup prompted me for Repair or Uninstall:



In this case you need to click Uninstall and relaunch the setup in order to install the 2015 version because choosing Repair will return an error.

After the installation is completed, the template Business Intelligence is available inside Visual Studio:

Dynamics CRM for iPad updated with CRM 2015 support

Microsoft updated its iPad app for Dynamics CRM (App Store) with CRM 2015 support.

The App description starts with an important note:
For CRM 2015, this app is supported on iOS 6, 7, and 8. For CRM 2013, it is supported on iOS 6 and 7.
My iPad is still on iOS 7 so I am not able to test this incompatibility.

The Changelog is the following:
  • Use multiple dashboards on the go
  • Personalize your Home page
  • Create records and capture notes while disconnected
  • Support for additional languages
  • Bug fixes
Some Screenshots:






November 24, 2014

My Top 10 Tips for Dynamics CRM Development

Each Dynamics CRM implementation is unique but the problems faced often are not.
Here my Top 10 Tips for Dynamics CRM Development:

  1. Custom Entities have their own privileges
    Developers normally have the higher privileges (like System Administrator role) when they customize CRM but end users not. This means that also Custom Entities privileges must be tuned (and don't forget the Golden Rule: Roles are additive).
    Link: Security role UI to privilege mapping

  2. CRM Online only supports FetchXML reports
    This is one of the well known limitations regarding CRM Online. Reports must use only FetchXML and more important this is true also for OOTB Reports: they are built using SQL Queries and they must be rewritten with FetchXML if you want to apply some changes.
    Link: Dynamics CRM 2011 Online default Reports not editable

  3. DateTime stored values are always in UTC
    DateTime fields in CRM UI show the right values but when you retrieve them by code are not the same? The automatic UTC conversion made by CRM is the reason. For this tip two links.
    Link: Truths about Dynamics CRM Date and Time
    Link: Dynamics CRM DateTimes - the last word?

  4. OData endpoint doesn't support all the CRM operations
    OData is a fast and convenient way for CRUD operations but you still need SOAP to perform some tasks like assigning a record.
    Link: Use web service data in web resources (OData and Modern app SOAP endpoint)

  5. Know the Sandbox limits
    CRM Online only supports Sanbox for Custom Workflow Activities and Plugins. Normally you will be fine, but for some operations you will face these limits (like the impossibility to call IP addresses).
    Link: Plug-in isolation, trusts, and statistics

  6. Dialogs can't be translated
    Dialogs are not included in the normal localization process used for other Dynamics CRM components. The suggested way is to create a dialog for each language you need to support.
    Link: Create solutions that support multiple languages
    Link: CRM Multidialog Multilingual or Language Specific?

  7. Generate the Early Bound classes only for the entities you need
    Personally I prefer Late Bound style but Early Bound has its big advantages. Do you know that you can create the classes only for some entities instead including the 8+ MB file generated by crmsvcutil.exe? Check the tool provided in the link.
    Link: CRM Early Bound Generator

  8. Use Pre-filtering in your reports
    CRM Pre-filtering is a very powerful function allowing users to add additional filters with an Advanced Find interface before the report runs.
    Link: Microsoft Dynamics CRM Pre-Filtering for CRM Reporting

  9. Always customize CRM using a solution
    Small CRM implementations or Dynamics CRM Online sometimes don't have a development environment, in this scenario often happens that customizations are done by "Customize the System" instead using an unmanaged solution. Also if the result looks like the same, not using a solution will make your changes less traceable (and it's better to don't talk about the ugly new_ prefix).
    Link: Introduction to solutions

  10. Use supported methods instead of SQL and DOM manipulation
    "I want the text bigger", "we can make this dropdown red when it's empty?", "this lookup must select only accounts", "we updated the records by SQL". They sound familiar to you? Often some requests can not be implemented using supported methods. Try to explain why and always suggest a supported alternative: instead of making the optionset background red, why not adding a small web resource (like a red dot) beside the field? A small scheduled console application that updates the records with the CRM Web Services can be a solution?
    Link: Supported extensions for Microsoft Dynamics CRM

November 20, 2014

ConditionOperator To FetchXml Operator

Dynamics CRM SDK contains the ConditionOperator enumerator that can be used when building a QueryExpression, but the SDK doesn't provide a way to convert a ConditionOperator to its FetchXml equivalent.

I created a static method that accepts a ConditionOperator enumerator and returns a string containing the equivalent FetchXml operator:

public static string ConditionOperatorToFetchXmlOperator(ConditionOperator conditionOperator)

string fetchXmlOperator = ConditionOperatorToFetchXmlOperator(ConditionOperator.EqualUserId); 
// fetchXmlOperator will be "eq-userid"
The library can be downloaded from Technet Gallery:
https://gallery.technet.microsoft.com/scriptcenter/ConditionOperator-To-065c445e

Note: the library contains the ConditionOperator for CRM 2011, CRM 2013 and CRM 2015.

October 29, 2014

Open CRM 4.0 and CRM 2011 instances using previous Internet Explorer versions

Dynamics CRM 2015 will be available soon but many customers are still using successfully CRM 4.0 (released in 2007) or CRM 2011 (nearly 4 years old) for their business processes. On the other hand we have Operating Systems and browsers updated regularly due to security reasons or machine upgrades.

Dynamics CRM has been always compatible with Internet Explorer but not with all the versions, we can't expect to use Internet Explorer 6 with the latest version or pretend to use IE11 with CRM 4.0.

As developer I faced this issue when I upgraded my PC to Windows 8 and Internet Explorer 11, I wasn't able anymore to use a CRM 2011 instance, the mobile version was prompted to me.



CRM 2011 is compatible with Internet Explorer 11, but it must have Rollup 17 installed, and that wasn't the case.
Which Internet Explorer version can be used in order to access correctly Dynamics CRM? Assuming we don't know if a rollup is installed, the IE versions that can be used with RTM are:

Internet Explorer 6 and 7 for CRM 4.0
Internet Explorer 7, 8 and 9 for CRM 2011
Internet Explorer 8, 9, 10 for CRM 2013

Based on this data Internet Explorer 7 is the best candidate for CRM 4.0 and CRM 2011. We can rely on a Virtual Machine in order to use a previous Internet Explorer version without messing up our current environment.

Creating a VM is a tedious process and it can take several hours. Lucky for us Microsoft provides a set of Internet Explorer VMs ready to be downloaded.
They are available at modern.IE, the intended use is to test a website compatibility with old browsers but they are also good to access occasionally to Dynamics CRM. I wrote occasionally because these VMs are not meant for a production use and the Windows version included is a trial.
If it's necessary to use constantly an older browser (or you have a Mac) it's better to build a proper VM with the right licenses.
The following VMs are available at modern.IE:

IE 6 - Windows XP
IE 8 - Windows XP
IE 7 - Windows Vista
IE 8 - Windows 7
IE 9 - Windows 7
IE 10 - Windows 7
IE 11 - Windows 7
IE 10 - Windows 8
IE 11 - Windows 8.1

Personally I use VirtualBox (you need to disable Hyper-V in Windows 8 to get better performances) but the VMs are available also for Hyper-V, VMWare, Virtual PC and Parallels.