Thursday, May 11, 2017

Save storage cost in Dynamics 365 (online) with Attachment Management solution

When files are attached/linked to Dynamics 365 records, they are stored in the CRM database which will have an impact on licensing cost depending of how much this functionality is being used. In Dynamics 365, 10 GB of storage is by default allocated to all CRM databases - for all organizations in the tenant) and 5GB is accrued per 20 full-users which are being licensed. (For more details see the Dynamics 365 Enterprise Edition Licensing guide). It is however possible to purchase additional database storage at roughly  4 EUR/GB/month. So if you accumulate 100 GB of files/documents per year – the cost might quickly rise – listed below is a rough estimate for 3 years.
Required storage Yearly cost
Year 1 100 GB € 4.800
Year 2 200 GB € 9.600
Year 3 300 GB € 14.400
There are a however a  number of options to externalize these documents/file blobs outside of the CRM databases and save money:
  • Use SharePoint Online as document storage – see Using SharePoint Online to store Dynamics CRM Online Documents for more details. This is the preferred solution if you also need to leverage SharePoint features such as document metadata, authoring/editing of Office documents, version management, etc… From a user perspective, this might however be a way of working which is not as smooth as expected.
  • Use Azure Blob storage to store your documents/files  - Azure Blob storage will roughly cost between 0.02 and 0.05 EUR/GB/month depending on reequired redundancy and type of storage (for an exact pricing  ). You will off course still need a solution to externalize these blobs. You can develop your own solution (you can use https://dynamicscrmbinarystorageoptions.codeplex.com/ as a starting point) or purchase a third party add-on such as ProStorageSaver from ProMX which will store attachments within Azure Blob Storage. Recently there is however a new solution available from Microsoft Labs on Appsource – Attachment Management
The Attachment Management solution is an add-on feature to dynamics 365 CRM Online to manage notes and email attachments using Azure blob storage. Attachment Management  not only  enables business users to optimize use of CRM Online storage but it also offers additional optional features using web resources such as multiple files upload with drag and drop support as well as  a web resources which allows to list all notes and email attachments in grid format, with download and preview of these attachment.

Figure 1. Screenshot of upload files control with drag and drop support

Figure 2. Grid view with e-mail and note attachments (including preview error)

This is a preview solution and there are still some issues:
  • Menu item for "Azure Blob Storage Settings" did not appear underneath Settings>Extensions – you can however manually add it through customization
  • Preview of documents within the grid listing does not seem to work correctly as visible in figure 2 above.
You also have to keep in mind that if you already have some existing attachments in Dynamics 365 (online), you will have to write some code to move them to Azure blob storage in the same way as the current solution does since this is not supported in the current version.






Monday, May 01, 2017

Dynamics 365 weekly reading list 01/05/2017

Lots of interesting news on Dynamics 365 the last couple of weeks – keep up to date by subscribing to this blog.

Technical topics (Configuration, customization and extensibility)

Topics for business analysts and power users

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
  • ConfigDataMover – Tool used for synchronizing data in different CRM environments (from @lucas_is)
  • Dynamics 365 workflow tools – this solution contains 30+ workflow activities which will help you to be more productive when designing Dynamics 365 process (from @demian_rasko )

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