Monday, April 24, 2017

The Dynamics CRM consultant tool belt

To be truly productive as a Dynamics CRM consultant you need a good toolkit to automate tedious or labor-intensive tasks. While you can solve anything by writing code – it just gets a lot easier when you can leverage the tools built by the CRM community. Listed below are the tools which I have used in the last 12 months – leave a comment if you think I have missed an essential utility in your tool belt.

  • Ribbon workbench for Dynamics CRM  - the standard for editing the Dynamics CRM Ribbon since CRM2011, it can now also be installed as a plugin for XRMToolbox
  • XrmToolBox – the Swiss army knife for CRM consultants, it is a windows application on which 30+ plugins can be added to automate a number of tasks – listed below are some of the XrmToolBox plugins I have recently used
    • Metadata Document Generator: a tool to generate Excel and Word documents with entities and attributes information - also take a look at  Spring Cleaning for your Dynamics CRM system about how you can use it to clean up your CRM system
    • Script Finder: lists all client events defined in an organization
    • Solution History for CRM 2013/2015/2016: allows you to view a historical list of solutions that have been imported, as well as display how many times a solution has been imported, version number that was updated and error/warning messages that were encountered during solution import
    • FetchXML Builder: Build and test FetchXML with all capabilities supported by the CRM platform, etc …
  • CRM Diagnostics Toolkit
  • Trace reader for Dynamics CRM (Codeplex)  
  • Level Up for Dynamics CRM (Chrome extension) 
  • Random test data generator 
  • Dynamics CRM/365 Developer Extensions - is a very worthy replacement of the SDK Developer Toolkit. It contains a lot of templates and will accelerate your development of plugins and workflows
  • CRM Rest Builder – a tool to generate Javascript code using the 2011 & Web API REST endpoints
  • XRM CI Framework - provides you with the tools automate the build and deployment of your CRM solutions. Use the framework to implement a fully automated DevOps pipeline, which will allow you to deploy more frequently with greater consistency and quality.
  • Fake XRM Easy – unit test library for Dynamics CRM/365 plugins and workflows

Also check out these other tool lists – Your essential toolkit for Dynamics CRM (from @jukkan)

Thursday, April 20, 2017

Getting a head start developing Dynamics CRM plug-ins

In this article I will explain what Dynamics CRM plug-ins are and which tools you can use to speed up the development of CRM plug-ins. The goal of this article is not to explain the logic behind plug-ins in detail, you can look a the links outlined in the references section of this blog post for that. I will however provide you with the most important information to get you started building your first Dynamics CRM plug-in with Visual Studio 2015 using the different tools : Microsoft Dynamics CRM SDK Templates, Microsoft Dynamics 365 Developer Toolkit, Dynamics CRM & 365 Developer Extensions or JonasPluginBase

A plug-in is an event handler (packaged as a .NET assembly) that can be used to intercept events generated from the  Dynamics CRM system, to perform a number of actions in code.  Apparently the underlying architecture of plug-ins has not changed a lot since Dynamics CRM 2011 so developers who have building these for previous versions can still use the same code base. So in essence plug-ins are .NET classes that implement the Microsoft.Xrm.Sdk.iPlugin interface. One or more plug-in classes can be contained in a .NET assembly (class library) – so you can just create a new class library project, add a reference to the Microsoft.Xrm.Sdk.dll (part of the SDK), add a class which inherits from Microsoft.Xrm.Sdk.iPlugin and implement the Execute method. You will also need to add to sign your assembly with a strong name.

But to let CRM know that your code needs to run, you will need to register your assembly to be invoked as part of the message execution pipeline that occurs when a CRM message is being processed. So first you will need to define on which type of message you want to react (e.g. associate tasks upon creation of a new account, setting default values, etc …) – these can be common messages such as create, retrieve (read), update or delete but also specific messages such as AddToQueue. Most message types are available for extension but there are some exceptions – check out Supported messages and entities for plug-ins.

Another design decision that you have to make when registering your plug-in, is whether it needs to run synchronously or asynchronously. Do realize that the choice between synchronous or asynchronous is also defining at which stage you can register your plugin e.g. an asynchronous plugin will only run post-operation and is not part of the database transaction (See Event execution pipeline for more details about the different stages).


The third design decision you will have to make, is deciding where your code will execute – Dynamics CRM provides two different options:
  • Full-trust (or non-isolated): synchronous plugins will run within the W3WP.exe process of IIS, and asynchronous plug-ins in the AsyncService which host the process. This is only possible in on-premise deployment and although slightly faster you will loose the benefits of …
  • Sandbox execution (or isolated mode): executes in the Microsoft.Crm.Sandbox.Workerprocess.exe process This should be your default choice unless you have a good reason not to use sandbox execution. This is the only option for CRM Online deployment but also has some limitations such as a two minute execution limit but also provides some benefits such as collection of run-time statistics about plugins-ins and custom workflow activities that run in the sandbox.  – I recommend that you read Plug-in isolation, trusts and statistics for more information as well as Understanding plugin sandbox mode.
To actually built the logic for your plugin you will need to use iPluginExecutionContext which provides information about the execution of the plugin such as (See Understand the data context passed to a plug-in for more information)
  • MessageName: name of the message in this case Create
  • Stage: stage that a plugin is being invoked e.g. 20 for Pre-Operation
  • PrimaryEntityName: name of the entity that triggered this message e.g. “lead”
  • InputParameters: Parameters from the request message – e.g. for a createrequest there is parameter of type “target” which contain
  • OutputParameters: Response message after the operation has completed
The next code sample shows how you use the PluginExecutionContext and how you leverage interfaces such as iTracingService (Provides a method of logging run-time trace information for plug-ins) and iOrganizationServiceFactory which allows you to create an instance of the organization service.

Option 1 : Dynamics CRM SDK Templates
As you noticed there is a quite a lot of plumbing code needed before you can get started. Fortunately there are alternative ways to start coding your CRM plugins such as the Microsoft Dynamics CRM SDK Templates (also part of the Dynamics CRM 2016 SDK). This provides a Visual Studio project template with a pluginbase class so that a lot of the repetitive plumbing code can be eliminated.



Option 2: Microsoft Dynamics 365 Developer Toolkit
Recently Microsoft also released an updated version of their CRM developer toolkit – Microsoft Dynamics 365 Developer Toolkit which is a set of Microsoft Visual Studio integration tools, focused on accelerating the development process. I recommend that you read Microsoft Dynamics 365 Developer Toolkit Series – Part 3  to get a feeling how you can use the Dynamics 365 Developer Toolkit.

Option 3: Dynamics CRM & 365 Developer Extensions
There are however also other tools out there such as the Dynamics CRM & 365 Developer Extensions from Jason Lattimer which is a very worthy replacement of the SDK Developer Toolkit. It contains a lot of templates and will accelerate your development of plugins and workflows by allowing for a one-click deploy directly from within Visual Studio but also contains building blocks for using unit test for your plug-ins. It currently supports Visual Studio 2012, 2013 and 2015.


Before you can use the CRM Developer Extensions you will need to change some settings in Visual Studio 2015 – go to Tools>Options and navigate to CRM Developer Extensions (See screenshot below)



Option 4: Microsoft Dynamics CRM/365 Plugin base class
Jonas Rapp also has a very light-weight and simple to use plugin-base class available which also includes tracing and timing information – check out https://github.com/rappen/JonasPluginBase

References:

Thursday, April 06, 2017

Weekly reading list 06/04/2017

 

Tuesday, March 07, 2017

CRM User Group Belux Chapter meeting - Data analytics and Business Intelligence

On March 23th, the Belux chapter of the Dynamics CRM user group organizes the first user group meeting – check out the agenda below and register for the Q1 2017 CRMUG Belux Chapter meeting on the CRMUG Belux site

AGENDA

  • 13:30 USER SUCCESS STORY - MARKETPLACE PORTAL AT I.P.M. GROUP (By Karim Ben Salah, Project Manager @I.P.M. )Group) As always, the Chapter Meeting starts with a user success story. This time I.P.M Group takes the stage to show us how they have combined MS Dynamics CRM and dot.net Open source NopCommerce to provide a powerful and flexible on-line e-commerce platform. The platform manages I.P.M.'s store, marketing product and offer catalog, huge amounts of real time transactions and complementary integrations with direct marketing tools. I.P.M Group has improved the user experience with a smart cross brand Single Sign-On, one-click payment checkout and a fully responsive web interface.
  • 14:30 HOW DATA ANALYTICS WILL BE PART OF YOUR COMPANY BOARD IN 2020 (By Julien Weber, Business Evangelist @ Wizata) Discover with real life cases how Advanced Data Analytics integrated to the Microsoft Environment is helping companies today to drive value, optimize processes or improve the decision making process. Get inspired on how Cortana Intelligence suite connected to Microsoft Dynamics 365 can help businesses to predict what�s next and stay one step ahead of competition.
  • 15:30 DYNAMICS 365 AND POWER BI (By Joris Poelmans, CRM Consultant @Realdolmen) This session will show you how Power BI can be put to practical use in combination with Dynamics 365. It is targeted at both business and technical users who want to take reporting and analytics to the next level. In this demo-heavy session you will learn to use the Power BI Designer to query CRM data, surface the data in dashboards and graphs and integrate it into your Dynamics 365 environment.
  • 16:30 ROUNDTABLE AND DRINK What's keeping you awake at night? Do you have a question to ask or a story to share with other Dynamics 365/CRM users? This is the perfect place and time.

PRACTICAL INFORMATION:

  • Doors open on : 23 March 2017 – 13:00
  • Location: AG Insurance - Room New York A Rue du Pont-Neuf / Nieuwbrug 17, 1000 Brussels

Gotchas when using curl on Windows

Curl is a command line tool for transferring data with URL syntax supporting multiple protocols such as HTTP, HTTPS, FTP,etc… It also supports SSL certificates and HTTP commands such as HTTP POST, PUT, GET, etc … It is by default installed on MacOS X but if you have Windows you will need to download it first – I’m using the Curl Win64 – Generic version 7.53.0 build by Viktor Szakats. 

Tip 1: You can use curl to test out REST APIs – unfortunately when I typed curl –XPUT ‘http://localhost/api/scorelead’ – I immediately got an error curl: (1) Protocol 'http not supported or disabled in libcurl.’ A very misleading error message because the way to resolve it on Windows is to just replace the single quotes with double quotes so use curl –XPUT “http://localhost/api/scorelead”

Tip 2: Check out Using Curl for ad hoc testing of RESTful Microservices for some other examples – another gotcha is that when you want to post a JSON payload you will need to escape quotes using this format -  curl -H "content-type:application/json" –XPOST “http:/localhost/api/authenticate” –d "{\"username\":\"user@test.com\",\"password\":\"test123\"}"

Technorati Tags: ,,,

Monday, March 06, 2017

Dynamics 365 weekly reading list 06/03/2017