Microsoft Dynamics 365 Blog

In the previous blog post we showed how a sales manager, Kevin, can use the charts and dashboards features to derive quick insights from his Microsoft Dynamics CRM data. In this blog we show how we can take such analyses to the next level by using the customization capabilities in Microsoft Dynamics CRM 2011.

Step 1- Understanding when to customize charts and dashboards

Earlier we showed how Kevin can use the chart and dashboard designer to create a quick dashboard that provides insights about Accounts, Contacts, Leads, Opportunities, Orders and Invoices. All the charts we created in that blog had just one level of grouping. This suffices for simple analysis. However, there is a lot more that charts can do! Imagine an account chart that not only shows when the account was modified but also what the current status of the account is, and allows for more control over the presentation properties of the chart.

Additionally the charts that we created earlier were rendered on the dashboard and thus showed aggregate information from all the records contained in their respective views. However, in some cases account managers need to access this information in the context of a specific account.

In this blog we show how such complex charts can be customized, and embedded in forms.

Step 2- Decide which views, charts, forms and dashboards need customization.

Let’s discuss two broad categories of customizations that we will illustrate in this blog. First are charts that group records by 2 criteria – date of modification and current status. Second are charts that customize the account form to show it in the context of a specific account. (Note that any form in CRM can be customized to show charts)

The following table summarizes the information that Kevin would like to track using the dashboard:

 image

Step 3- Create the solution and its components

Note: The chart customizations that we illustrate in this blog can be done on either system or user charts. However forms can be customized only by administrators/customizers.

If the customizations need to be shared with all users in an organization, it is a good idea to create these as part of a solution package and publish the solution. This way the solution can also be reused across different CRM organizations.

Creating a solution in Microsoft Dynamics CRM 2011 is quite easy; I created a solution called CRMTrackingDashboard for the purpose of this blog. To begin with we need to add the entities we need into the solution using “Add Existing” feature in the Solutions.

Step 4- Create the views needed to solve your problem

We need to create a new view for each of the components described above. Creating these new views is straightforward. I have created a new view for each of these entities with a filtering criteria that says “Modified On Equals This Month”. All these views were created as part of the CRMTrackingDashboard solution.

Step 5 – Create the Charts needed to solve the problem

Customizing charts to include additional grouping criteria and presentation properties requires XML definitions for these charts. To make the creation and editing of these charts a little easier,, one can always create a basic chart definition using the chart designer, export it to XML, hand edit the additional changes, and import the definition back in.

We will use the charts designer as a starting point for creating a first draft of the account chart definition. To create the above chart for the Accounts entity –

1. Go to Accounts entity in the solution explore

2. Go to the Charts Node

3. Click on New Chart

4. Create a chart by giving grouping criteria as the “Modified on”, and set the date-grouping to day. Set the name of this chart as “Daily Account Status”

5. Export this chart definition using the “Export Chart” feature in Actions menu.

We are now ready to hand edit this charts definition and add the additional grouping criteria.

Since our second grouping criteria is the Status field, we need to add this into the “datadescription” part of the chart definition. The exact criteria that we need to add is –

<attribute groupby="true" alias="groupby_status" name="statecode" />

Having added this into the existing chart definition, the updated chart’s data description looks like the following:

  <datadescription>
    <datadefinition>
      <fetchcollection>
        <fetch mapping="logical" aggregate="true">
          <entity name="account">
            <attribute alias="aggregate_column" name="name" aggregate="count" />
            <attribute groupby="true" alias="groupby_column" name="modifiedon" dategrouping="day" />
            <attribute groupby="true" alias="groupby_status" name="statecode" />
          </entity>
        </fetch>
      </fetchcollection>
      <categorycollection>
        <category>
          <measurecollection>
            <measure alias="aggregate_column" />
          </measurecollection>
        </category>
      </categorycollection>
    </datadefinition>
  </datadescription>

We also need to tweak the presentation a little so that we can specify the exact presentation properties that we would like to use. Here is the presentation description that we would like to use:

<presentationdescription>
    <Chart Palette="None" PaletteCustomColors="97,142,206; 209,98,96; 168,203,104; 142,116,178; 93,186,215; 255,155,83; 148,172,215; 217,148,147; 189,213,151; 173,158,196; 145,201,221; 255,180,138">
      <Series>
        <Series ChartType="StackedColumn" IsValueShownAsLabel="True" Font="{0}, 9.5px" LabelForeColor="59, 59, 59">
          <SmartLabelStyle Enabled="True" />
        </Series>
      </Series>
      <ChartAreas>
        <ChartArea BorderColor="White" BorderDashStyle="Solid">
          <AxisY TitleForeColor="59, 59, 59" TitleFont="{0}, 10.5px" LineColor="165, 172, 181">
            <MajorGrid LineColor="239, 242, 246" />
            <MajorTickMark LineColor="165, 172, 181" />
            <LabelStyle Font="{0}, 10.5px" ForeColor="59, 59, 59" />
          </AxisY>
          <AxisX TitleForeColor="59, 59, 59" TitleFont="{0}, 10.5px" LineColor="165, 172, 181">
            <MajorGrid Enabled="False" />
            <MajorTickMark Enabled="False" />
            <LabelStyle Font="{0}, 10.5px" ForeColor="59, 59, 59" />
          </AxisX>
        </ChartArea>
      </ChartAreas>
      <Legends>
        <Legend Alignment="Center" LegendStyle="Table" Docking="Bottom" Font="{0}, 11px" ShadowColor="0, 0, 0, 0" ForeColor="59,59,59"></Legend>
      </Legends>
      <Titles>
        <Title Alignment="TopLeft" DockingOffset="-3" Font="{0}, 13px" ForeColor="59, 59, 59"></Title>
      </Titles>
    </Chart>
  </presentationdescription>

The hand edited chart definition can be imported back into CRM using the Actions->Import Chart feature

Step 6- Create your dashboard

Now that our views and charts have been created we are now ready to add a dashboard into the solution. Here are the steps –

1. Go to the dashboard node within solutions

2. Click on create new dashboard

The steps for creating a system dashboard are same as the steps for creating a user dashboard, which was described in our previous blog. Hence we will not repeat it here. However note that the customizer can designate one dashboard in the solution as a system default dashboard. The system default dashboard applies to all users in the org. The system default dashboard settings, can be overridden by the user default dashboard settings for each user.

Dashboard Screenshot

clip_image002

Step 7- Customize the Accounts form

WE mentioned earlier that we would also like to show information in the context of an account. In order to do this –

1. Navigate to the Account node in solutions

2. Open the account form using the form editor

3. Insert charts on account – to insert the Orders on the account follow the steps below

    a. Click on the sub-grid icon in the form editor ribbon

    b. Choose entity as Orders

    c. Select “Show Related Records”

    d. Select the view “Orders Modified This Week”

    e. Click on the show chart only checkbox

4. Repeat Step 3 for adding other charts on the dashboard such

Here is the screenshot of the Account form showing charts for Contacts, Opportunities, Quotes, and Orders in the context of that account:

clip_image004

Conclusion

It is evident from the above steps that the charts and dashboards features in Microsoft Dynamics CRM 2011 are easy to use and powerful at the same time. While Dashboards can be created by business end users in Microsoft Dynamics CRM 2011, there is also room for developers to enhance these dashboards so they meet a wider range of business needs. We hope the steps outlined above will help your organization make good use of these features. We will have more blogs in the future to showcase further analytics related capabilities.

Cheers,

Siddhartha Rai


We're always looking for feedback and would like to hear from you. Please head to the Dynamics 365 Community to start a discussion, ask questions, and tell us what you think!