May 24, 2017

Xrm.Page.context.getVersion is now a supported method, use it!

Recently the MSDN page regarding the Client-side context methods of Dynamics 2016/365 has been updated and thanks to the Dynamics team a new method is inside the documentation: Xrm.Page.context.getVersion.

Some developers are already using this method in their code, personally I didn't because I had not the necessity to differentiate between the 8.x endpoints.

The method returns a string containing the full version in the Major.Minor.Build.Revision format, an example is "8.2.1.185".

In the previous CRM versions if we want to get the version from the client we had two ways:
  • call the RetrieveVersionRequest message using the SOAP endpoint (example)
  • check if a specific CRM function exists (example)
I used often the second way because I always considered doing a server call (often synchronous) not a good choice for the script performance.

Why we want to know the current CRM version? Because some functions are available only from a specific version, like the one to execute a workflow: the Microsoft.Dynamics.CRM.ExecuteWorkflow introduced with the 8.2 release.

But for the Web API endpoint we need to provide only Major.Minor and not the full version, therefore a transformation is necessary.

The following code maybe will be considered exaggerated by someone but creating a robust piece of code will reduce the necessity to change the script in the future:
function getCurrentVersion(context) {
    if (context.getVersion == undefined) { return ""; }
    var versionArray = context.getVersion().split(".");
    if (versionArray.length < 2) { return ""; }
    return versionArray[0] + "." + versionArray[1]; 
}
The result from the "8.2.1.125" is "8.2" ready to be inserted inside your Web API url.

Few considerations:
  • If the version cannot be retrieved I decided to return an empty string, but you can return null, throw an exception, call another method, set a default value, etc etc...
  • the function requires the context, in this way you can use in the form scripts (like an onload event) or inside a WebResource
  • I decided to split the string to an array using the dot (.) I think this is the most robust way compared to doing a substring or expecting a second dot in the string

May 15, 2017

CRM Saturday Zurich: recap of the Community Event

Last weekend I attended #CRMSaturday in Zurich, for those not familiar with the name, CRM Saturday is a series of events across Europe (but they are going global with the July event in Australia) focusing on Dynamics 365 for Customer Engagement (or Dynamics CRM if you prefer).

Conferences and events like this are an important part of the CRM ecosystem, when you work on a platform like Dynamics 365 that implements new features rapidly, a community event can be a perfect opportunity to keep yourself up to date learning something new or go deeper with a specific functionality.

The location for the Zurich chapter was the Microsoft Offices in Switzerland, a perfect venue considering that this was a joint event with SharePoint Saturday Events, the available tracks in totally were three (2 for SharePoint and 1 for CRM).

Stefano Tempesta, one of the organizers of CRM Saturday, gave an introduction before the keynote of Kathrine Hammervold from Microsoft Norway.
The CRM track started with the session of Baris Kanlica titled "Dynamics 365 new features and deprecations", with the upcoming release this is an hot topic and personally I learned about the use of control notifications (Xrm.Page.getControl(arg).setNotification(message,uniqueId)) The next speaker was Razwan Choudry with his session about Solution Management. How to manage solutions, how to implement versioning and the infamous "Add all assets" checkbox were some of the topics covered. The message was to put more attention on the maintenance and the deployment of a solution, and I couldn’t agree more. After the lunch break was the turn of Marius Agur Pedersen with his session about Azure. He focused on Azure Service Bus and Azure Key Vault, we can bet that Azure and Dynamics 365 will be more integrated in the future. I am often inclined to don't use Azure Service Bus, but with Marius reassurances about the bus performance I will try it again. The following session was with Jordi Montaña and his testing framework Fake Xrm Easy. Unit testing is a must for medium and big projects, but should be also a priority for smaller projects that contains only a couple of plugins. The framework he created is impressive, I know how broad and different are the CRM messages and the IOrganizationService and to mock all that stuff requires countless hours. Next to the stage was Christoph Mäder with his session to improve the performance of a Dynamics CRM/365 OnPremise instance. Many customers still prefer to have their CRM in house or they are not ready to move to the Cloud, but this doesn't mean that they can't tune their instance or take advantage of some possibilities offered by an OnPremise installation. The last one to speak was Mohamed Mostafa with the other side of the medal: Considerations for Cloud Dynamics 365 Deployments. His session went through the major aspects of an Online implementation, the compromises and the big advantages to have Microsoft taking care of your instance, considering also the upcoming EU GDPR (General Data Protection Regulation). It was an amazing event and experience for me, I had the chance to met in person people that I know virtually from a long time. Despite some tweets that list me as speaker, I only attended and I was not involved in the organization of the event, all the credits goes to the other guys in the next picture, they used their time and energy to make this happen, I'm honored to know them and they are an inspiration for the community. CRM Saturday was free, so a "thank you" should be made also to the sponsors. Bottom line: attend the next CRM Saturday!