Tuesday, July 26, 2016

Dynamics CRM - Google Charts Mashup

The combination of HTML Web Resources, Web API and Javascript libraries in Dynamics CRM allows you extensively customize the user interface. Here I am going to show how you can create a mashup of these technologies to show a custom appointments timeline chart on the account form. The out of the box charts are somewhat limited In Dynamics CRM however Google Charts has a vast array of charts which are free to use so I will use their timeline chart for this demo.




To accomplish this I created a HTML web resource which I added to the account form. Once it loads it runs JavaScript that does the following
  • Get the ID of the current account record
  • Web API call to get the appointments that reference the account id
  • Populate the Google Chart datatable with the Json returned
  • Call the Draw method to Render the chart
    The code is below  and you can see it references the Goggle Charts JavaScript libraries.

Sunday, July 17, 2016

Open Dynamics CRM Form Using Alternative Key

The introduction of alternative keys in Dynamics CRM 2015 give us the ability to add unique identifier fields to entities in CRM. This is particularity useful when you need to store an unique identifier from an external system against a CRM record. At the same time the Upsert command was added to the SDK to facilitate updating records in Dynamics CRM from external applications using alternative keys. You no longer needed to store or lookup the Dynamics CRM Id when the accessing CRM data using the SDK.

Another typical requirement when integrating Dynamics CRM with external systems is to create a hyper link in the external system to open the corresponding record in CRM.  In this post I am going show how you can do this using the alternative key rather than the CRM Id.
This is accomplished by opening a HTML web resource page in CRM passing the alternative key as a parameter and using this to retrieve the CRM Id which is then used to open the form.

In this example I created a HTML web resource page called OpenFormAltKey and added a hyperlink in my external system that opens this page and passes the alterative key of the current record. HTML web resource can only accept a single custom parameter called data so the alternative key need to be encoded in the data parameter,

When the page loads it runs a Javascript function called GetDataParameters to decode the parameters and extract the alternative key. It then calls the function openformWithAlternativeKey which does a Web Api call to get the CRM ID for the account record with the alternative key. It then calls the openEntityForm method to open the account form for the CRM Id. 


    document.onreadystatechange = function () {  
      if (document.readyState == "complete") {  
        var params = getDataParameters();  
        openFormWithAlternativeKey(params["altkey"]);  
      }  
    }  

You take this example and expand it so the entity name and form name could also be passed as parameters making it much more generic and flexible. more code below

Saturday, July 09, 2016

Tracing in Dynamics CRM Custom Assemblies


When writing custom assemblies for Dynamics CRM you can add  trace messages to your code to help track down problems and  identify performance issues. Trace messages can logged by initializing the tracing service in your code and calling the Trace method. I usually add the execution time as part of my trace messages especially when calling external services as this can be a performance pain point which may be difficult to track down.


ITracingService logger = (ITracingService)ServiceProvider.GetService(typeof(ITracingService));

logger.Trace(DateTime.Now.ToString("mm:ss:ffff") + ": Calling FX Rate");
this.callFxRest();
logger.Trace(DateTime.Now.ToString("mm:ss:ffff") + ": FX Rate");




If an exception is raised in a plugin the traces messages are included in the error text returned to the user.


Friday, July 01, 2016

Interactive Service Hub - Sub Account Activity Issue

I have started to have a look at the capabilities of interactive service hub for a potential project. The interactive service hub is a new user interface for Dynamics CRM currently targeted at service functionality. The interactive service hub user interface is very slick and although only a subset of the core entities are supported I strongly believe that this will be come the new default user interface for Dynamics CRM going forward. It uses the tablet layout engine and as a result it is much quicker and responsive. Just like the tablet app you do however get a slight delay when changes have been made as the customizations need to be downloaded to your device.

That said I noticed when checking it out that the surfacing of activities from related records to parent accounts does not seem to work. Using the web client when you look at a parent account the activities, cases and opportunities are rolled up from sub accounts. This gives the user a complete picture of all interactions in a company hierarchy. This does not see to happen in the interactive service hub. If you look at the screen shots below you can see the difference when you view an account in the new ui and the web client.