Posts Tagged ‘Dynamics 365’

(Step By Step) Surface Power BI Reports in Dynamics CRM Dashboard

In this article, I am going to provide ‘Step-by-Step’ details on how to:

  • Add ‘Power BI’ subscription to your existing Office 365
  • Connect to your ‘Dynamics CRM Organization’ from BI
  • Render Power BI reports in CRM Dashboard.

What’s Power BI and How is it different from SSRS?

  • Power BI offers basic data wrangling capabilities like Excel’s Power Query.
  • It also lets you create interactive visualizations, reports and dashboards with a few clicks and handle files that are too large for Excel.
  • On the other hand, SSRS is meant for “static” reports. Something that will be shown always as defined and printable.

Steps to add ‘Power BI’ subscription:

  • As a pre-requisite, create your 30 days Dynamics 365 free trail.
  • Login to ‘’ and open ‘Admin’ dashboard
  • Go to ‘Billing -> Purchase services -> Power BI (free) -> Buy now
    • Note: This requires you to provide credit card details and INR 2 will be charged after successful purchase.

D365 - Power BI

  • After successful purchase, open ‘’ on another tab of the browser and click ‘Sign In’

D365 - Power BI - Start

  • Click ‘Start’

Connect to Dynamics CRM organization from Power BI:

  • To connect to CRM Organization from ‘Power BI’, you need to install one of the ‘Content Packs’

D365 - Power BI - Content Packs

  • Click on ‘Get’ button from ‘My organization’ section
  • From the available list, choose any of the Dynamics CRM related Apps (I chosen ‘MS Dynamics Online Sales Manager’ for this demo, from the ‘Apps’ tab)

D365 - Power BI - CRM Sales Manager Pack


  • Click on ‘Get it now’ and you will be asked to provide CRM credentials.
    • Provide ‘CRM Organization URL’ details and ‘Last Month Of the Fiscal’

D365 - Power BI - Connect To CRM

    • Choose ‘Authentication Method’ as ‘OAuth2’

D365 - Power BI - Connect To CRM - OAuth

  • Post successful login, you would see ‘Importing Data’ message

D365 - Power BI - Connected To CRM - Importing Data

  • Give it few seconds and you would see beautifully rendered reports

D365 - Power BI - Connected To CRM - Dashboards.PNG

Display ‘Power BI’ reports in CRM Dashboard:

In previous versions of CRM, only option to bring ‘Power BI’ reports are by placing an IFrame in Dashboard and set the PowerBI URL. Its easily configurable now.

  • Connect to your Dynamics CRM Organization
  • Go to ‘Settings -> Administration -> System Settings -> Reporting -> ‘Allow Power BI….’=Yes

D365 - Enable embed Power BI

  • Create a new Dashboard
  • Select the placeholder and from the Report add options, click ‘Power BI Tile’

D365 - New Dashboard - Add Power BI Tile

  • Pick one of the available ‘Power BI Reports’

D365 - Add Power BI Tile - Pick Dashboard

  • Save the Dashboard
  • Go to ‘Sales -> Dashboard’ and pick the created ‘Dashboard’

D365 - Open Dashboard in D365



Solution Import Failures / Publish Customizations Failures – Dynamics 365

February 12, 2017 Leave a comment

Recently we upgraded our organizations to Dynamics 365 and we were getting solution import failure while moving solutions between organizations.

Below are different kind of error messages popped up.

  • Getting Dependency Calculation There was an error calculating dependencies for this component. Missing component id {0}
  • Failure trying to associate it with CustomControlDefaultConfig
  • Can’t insert duplicate key for an entity


  • In our case the root cause for all these import failures was “customcontroldefaultconfig” component with Custom entities.
  • If there is any orphan record exists in “CustomControlDefaultConfigBase” table it would cause solution import failure or ‘Publish Customizations’ error.
  • The issue seems a product issue and got fixed in Service Update 5 of CRM 8.1.0 but resurfacing again in Dynamics 365.

Prevention Tip:

  • If you are adding an entity to your solution, always add ‘Primary key’ field
    • In the source environment open the Solution being imported
    • Open each Entity and expand Fields
  • Make sure that every entity has its “Primary Key” added to the solution.



CRM On-Premise

  • Check if any orphan records in CustomControlDefaultConfigBase tabel. (Use below queries)
    • SELECT * FROM CustomControlDefaultConfigBase WHERE PrimaryEntityTypeCode NOT IN (SELECT ObjectTypeCode FROM Entity)
  • Note: before continuing, a backup database is recommended.
  • Delete from the Target environment the CustomControlDefaultConfig records with orphaned Object Type Codes:
    • DELETE FROM CustomControlDefaultConfigBase WHERE PrimaryEntityTypeCode NOT IN (SELECT ObjectTypeCode FROM Entity)

CRM On-line

  • Create console application to delete the orphan record in CustomControlDefaultConfigBase using CRM SDK
  • Refer this URL for code.


Dynamics 365 Mobile Client – Script to get Longitude and Latitude and pin to Maps

January 14, 2017 1 comment

With the new Dynamics 365 Mobile client, we got a new API Xrm.Utility.getCurrentPosition which returns the current location coordinates.

This API only works with Mobile Client and referring this in Web Application would cause script error.


We need to Enable User Location setting on the device

  • Go to Settings -> Device Integration Settings


  • Enable “User Content and Location”


Script to get coordinates:

function onload() {
var isCrmForMobile = (Xrm.Page.context.client.getClient() == “Mobile”);

if (isCrmForMobile) {
(function (location) {
Xrm.Utility.alertDialog(“Latitude: ” + location.coords.latitude +
“, Longitude: ” + location.coords.longitude);
function (error) {



HTML File to Read Coordinates and Show in Map



Code snippet – Connect to Dynamics CRM using Organization Service C#

December 11, 2016 1 comment

Below is the sample code to connect to Dynamics 365/CRM online 2016 using simplified connection.

This sample authenticates the user with the Dynamics 365 web services by using the CrmServiceClient and methods.

Required CRM SDK .Dlls:

  • Download the SDK to get the required .dlls
Required dlls

Required dlls

Required Namespaces :

using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Tooling.Connector;

Configure connection string in App.Config:

O365 Connection strings

O365 Connection strings

C# Code:

String connectionString = GetServiceConfiguration();
CrmServiceClient conn = new CrmServiceClient(connectionString);

// Uncomment below statement in case you want to use Organization Service
// IOrganizationService orgService = conn.OrganizationWebProxyClient != null ? conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy;

OrganizationServiceProxy orgService = conn.OrganizationServiceProxy;

// To impersonate, set the caller GUID
orgService.CallerId = new Guid(“D0DED6CA-5A65-E611-80DD-FC15B42877A8”);

// Create Account

Entity account = new Entity(“account”);
account[“name”] = “Peter Parker”;
Guid accountId = orgService.Create(account);

// Who Am I Request

// Guid userid = ((WhoAmIResponse)orgService.Execute(new WhoAmIRequest())).UserId;

catch (Exception ex){
Console.WriteLine(“Exception : ” + ex.Message);

// To Read Connection Strings From <App.Config>

private String GetServiceConfiguration(){
// Get available connection strings from app.config.
int count = ConfigurationManager.ConnectionStrings.Count;

// Create a filter list of connection strings so that we have a list of valid
// connection strings for Microsoft Dynamics CRM only.
List<KeyValuePair<String, String>> filteredConnectionStrings =
new List<KeyValuePair<String, String>>();

for (int a = 0; a < count; a++)
if (isValidConnectionString(ConfigurationManager.ConnectionStrings[a].ConnectionString))
(new KeyValuePair<string, string>

// If one valid connection string is found, use that.
if (filteredConnectionStrings.Count == 1)
return filteredConnectionStrings[0].Value;

return null;

private Boolean isValidConnectionString(String connectionString){
// At a minimum, a connection string must contain one of these arguments.
if (connectionString.Contains(“Url=”) ||
connectionString.Contains(“Server=”) ||
return true;

return false;

Refer MSDN article for more details.


Dynamics 365 – PowerApps

November 20, 2016 Leave a comment

PowerApps is a service for building and using custom business apps that connect to your data and work across the web and mobile.

PowerApps enables power users in line of business roles to easily build and deploy business apps – without the time and expense of custom software development.

In this article, I am going to create a simple PowerApp which allows me to work with my Case records.

Step by step creating App:

  • Subscribe for 30 days trail of Office 365
  • After sign up, on the Home page, select “PowerApps”


  • It will take to ‘PowerApps’ home screen.
  • To create new App, click on “New app” and from the popup,
    • If you have machine running on Windows 8 or Windows 10, Choose “PowerApps Studio for Windows” which will take you to Store to download the App
    • Choose “PowerApps Studio for Web” to design in browser.


  • I chose “PowerApps Studio for Windows” and downloaded the “PowerApps” from Windows Store


  • After download, launch the “PowerApps” studio.
  • As we are creating App to work with CRM Cases, choose “Dynamics 365” as your Data Source
Connect to Dynamics 365

Connect to Dynamics 365

  • Choose the ‘Dataset’ as your Organization (Its “MS” for me)
  • Choose the ‘Table’ as “Cases” entity and click on “Connect”
Connect to Organization Data Set and Cases Table

Connect to Organization Data Set and Cases Table

  • Studio opens up the designer with default screens (i.e.,Browse, Details, Edit) for Case’s  records.
Layout screens

Layout screens

  • You can add/remove fields or icons on the screens or create a new screen.
  • Once the design completes, click “ File -> Save” to save the App
Save the App

Save the App

  • I saved the App as “My First App”

Run the App:

  • Go to PowerApps home screen and select the App to run.
My App

My First App

  • Click the App and it will run and pull the Cases from my Dynamics 365 organization.
My first app running

My first app running

Share the Power App:

  • Also, App can be shared across the Organization or to specific Users.
  • Select the App and click on ‘Share’ option



Categories: Dynamics 365 Tags: ,

Dynamic’s 365 – CRM Developer Toolkit

November 12, 2016 1 comment

The much-awaited CRM Developer Toolkit Beta 1 has been released and it supports Visual Studio 2015,2013 and 2012 versions.



Its public Beta 1 and can be downloaded here


Dynamics 365 New Feature – Editable Grid

November 5, 2016 Leave a comment
  • Editable grid is a new custom control in Dynamics 365 that provides inline editing capabilities on web and mobile clients


  • It can group, sort, and filter data


  • Editable grid is supported in below grids on the web client, and in dashboards and form grids on the mobile clients.
    • Homepage grid,
    • Form grids
    • Sub grids
  • It honors the read-only field metadata and field-level security settings.
  • Editable grids also support business rules and form scripting.
  • Editable grids do not support roll up associated views
  • Editable grid can be configured on the entity only if its Customizable

Configure Editable Grid on Account Entity:

  • Go to Customization -> Entities -> Account -> Controls -> Add Control
Add grid

Add grid

  • Adding Look up: We can configure look up field on Editable grid with Search option.


  • Similarly we can also add  ‘Nested Grid View’ (Only supported for Tablet and Phone clients).

Editable Grid Events:

Editable grid supports the following events



  • OnRecordSelect
    • Event occurs when a single row is selected in the editable grid.
    • This event won’t occur if a user selects different cells in the same row, or selects multiple rows.

// Register this event on ‘onRecordSelect’ event

function gridRowSelect() {

// Read selected rows from editable sub grid
var selectedRows = Xrm.Page.getControl(“subGridAccounts”).getGrid().getSelectedRows();

  • OnChange
    • Event occurs when a value is changed in a cell in the editable grid and the cell loses focus.
    • This event can also occur when an attribute value is updated using the setValue
  • OnSave
    • Event occurs, when,
      • There is a change in the record selection.
      • Explicitly triggering a save operation using the editable grid’s save button.
      • Upon sort, filter, group, pagination, or navigation operation from the editable grid while there are pending changes
    • Editable grid suppresses duplicate detection rules up on Save.
    • If a user edits multiple columns of the same record in sequence, the OnSave event will only be fired once
  • Editable grid control does not implement an auto-save timer

Configure Editable Sub Grid:

  • Sub grid on the form can be configured as Editable grid
  • I have a Custom entity ‘Company Accounts’ having 1:N relationship with ‘Accounts’
  • I added a Sub grid ‘subGridAccounts’ on the ‘Company Accounts’ form
  • To make ‘subGridAccounts’ grid as Editable, Double click the grid to open ‘Properties’
  • Add ‘Editable Grid’ Control. You can add Grid events too.
Configure- editable sub-grid

Configure- editable sub-grid

  • Editable Sub Grid looks as below
Sub-grid on form

Sub-grid on form

Refer MSDN for more info.