Sonoma Partners Microsoft CRM and Salesforce.com Blog

Project Service - The more you know

Today's post is written by Jeff Meister, Principal Consultant at Sonoma Partners.

The release of Microsoft CRM Online Spring Wave brings some great news for those of us focused on delivering quality customer service to our clients. 

In addition to the integration with two recent Microsoft acquisitions, ADX Studios (customer portal) and FieldOne (field service), Microsoft is also releasing  a new Project Service solution. Project Service is a PSA (Project Service Automation) solution that provides an end to end solution for delivering professional engagements and will be ideal for service-based firms.

Picture141-1024x605

Today, I wanted to walk you through a high-level overview of the functionality based on what we've learned to date about the solution.

Opportunity Management

CRM has traditionally handled opportunities with product line items. Project Service updates this functionality to handle what sales of service projects would need. Some key highlights would be contracts and labor rates, collaboration, practice lines, price lists and quotes; all while following your pre-defined sales methodology and best practices.

Project Planning

This is where things start to get interesting. This aspect of the solution brings key components from MS Project, and embeds them directly into CRM. Users are able to store templated project plans which are then modified and used for estimating, definition and timeline/budget tracking throughout the project lifecycle. Having these tools accessible within CRM allows for more accurate quoting, ensuring profitability and resource estimates are aligned early in the sales process. It also provides enterprise visibility to project status.

2

Resource Management

The solution takes the pre-sales planning work and applies that to your staffing model for demand fulfillment. This can be done across various staffing models. Whether or not your project manager or team members access the demand pool directly, or if you have centralized resource managers, resource scheduling can be done via the new solution, taking into account availability, capacity and skill sets while maintaining competencies and proficiencies.

(On a side note, we are really excited to see where this part of the solution can go when paired with machine learning!)

Time and Expense

This one is easy…mobile and desktop support for time and expense entry, with routing and a built-in process for approval. Having these data points tied directly to the project in CRM also provides the ability for immediate impact to project financials. Plus, you can access these functions through mobile applications.

Billing

Having all the project related data (contract, time reporting, expenses, billing details) under one roof allows us to easily source our invoices directly from the solution. We don’t believe this will be a full blown replacement for an ERP backend, especially at the enterprise level. That being said, this is a great direction to see the product headed, and we expect integration with other ERP systems to be available.

Analytics

The Project Service solution will have built in BI capabilities around actual records for financial events, profitability, and utilization. It is also expected to have content packs available for PowerBI, allowing for rich dashboards and ad hoc analytics. 

1

Sonoma Partners was fortunate enough to be an early participant with this process. The solution uses native functionality in conjunction with custom screens to deliver an intuitive and very compelling application targeted for firms that manage projects, time, and resources. The solution is easy to install and configure on your base CRM Online deployment. 

As mentioned above, Project Service is available as part of the Spring Wave for CRM Online.  And, we have our fingers crossed that we will see solution available for the on premises version at some point as well. Pricing details are yet to be published, but check back for more details as those become available.

Topics: Microsoft Dynamics CRM Microsoft Dynamics CRM Online

Lookups - Null vs Empty Array

The other day I discovered an interesting ‘gotcha’ when working with a lookup in JavaScript.  A business requirement called for some JavaScript to be registered when a lookup value changed and then execute certain logic based on if the lookup had a value or not. 

This is pretty straightforward logic and could be handled easily with the following code:

var customerValue = Xrm.Page.getAttribute('parentcustomerid').getValue();
if (!customerValue) {
   // do some logic
}
else
{
   // do some other logic
}

Come to find out, this works for the most part but there is one scenario where it falls short which is where the ‘gotcha’ comes in. 

  1. Record form loads and the lookup doesn’t have a value
  2. The lookup has a value and the user selects the lookup and hits the “Delete” key
  3. The lookup has a value and the user clicks the magnifying glass, then “Look Up More Records” and then clicks “Remove Value” on the subsequent dialog
In the first two scenarios with the above JavaScript code, the customerValue variable will be null and will work as expected.  In the third scenario, the customerValue variable will be an empty array and not work as expected as it isn’t null.


Therefore we need to update the block of code with the following:

var customerValue = Xrm.Page.getAttribute('parentcustomerid').getValue();
if (!customerValue || customerValue.length == 0) {
   // do some logic
}
else
{
   // do some other logic
}

Now the code is flexible and will handle all 3 scenarios where the lookup value doesn’t exist.

Note:  This was tested in CRM 2015 Update 1 and CRM 2016

Topics: Microsoft Dynamics CRM Microsoft Dynamics CRM 2015 Microsoft Dynamics CRM 2016 Microsoft Dynamics CRM Online

Programmatically Editing Searchability of Fields

Today's post is written by Matt Dearing, Development Principal at Sonoma Partners.

We recently had a request from a customer to flip the “searchable” function on a number of fields from on to off; preventing users from searching on these fields in advanced find.

When you only want to modify a handful of fields, the easiest way to do this is through native customizations by editing the attribute’s configuration to flip its searchable value to “No.” If there are several fields to update, a great option is using the XrmToolBox’s Attribute Bulk Updater which, as the name suggests, lets you update specific attribute metadata in bulk.

However, in this case, the customer had a list of 1000+ fields across 20+ entities they wanted to have disabled to reduce clutter in advanced find. This would have taken a significant amount of time if we used the native customization editor or even the Attribute Bulk Updater, and both methods would have been prone to error. We decided to convert their list (which was originally the field and entity Display Names) to schema names and update programmatically.

The customer gave us a CSV file with a column for entity display names and another for attribute display names. Then to retrieve the schema names we used MetaBlast to export the metadata of the customer’s org. We planned on using VLOOKUPS to match the display names to the schema names but because a number of fields repeated across entities we needed to create a unique identifier for the lookup. We added an additional column to the customer-provided CSV file and the MetaBlast file and filled it with a concatenation of the entity and attribute name. With a unique identifier in place we used the VLOOKUP function to retrieve the schema names.

1

 var attribute = entity.Attributes.Where(x=> x.LogicalName == csvFieldName).First()
attribute.IsValidForAdvancedFind.Value = false;
orgService.Execute(new UpdateAttributeRequest()
{
	Attribute = attribute,
	EntityName = key
});
*The above code was in a try catch to print out those csv fields that could not be found or not be updated.

Next we wrote a simple LinqPad script that would: loop through the rows of the CSV, leveraging the CsvHelper NuGet package to bring the entities and attributes into memory; query each entities metadata; match the csv row attribute to the entity attribute metadata; then set the attribute metadata’s “IsValidForAdvancedFind” property to false and update the attribute.

Finally we published all customizations and voila the fields were updated. There were a handful of fields whose “IsValidForAdvancedFind” property was not updatable, and this could have been checked for in the LinqPad script, but with this being a quick one time run we just printed those fields out to the console window and let the customer know which fields could not be updated.

In the end this saved a ton of time from updating each field manually, and reduced the number of errors that manually clicking would have introduced. The customer was excited that we were able to clean up their searchable fields. It’s always good to look for existing tools to help speed up customization work, but sometimes a quick script is the best way to go especially if updating a very large number of customizations.

Topics: Microsoft Dynamics CRM

Lost in CRM Translations

Today's post is written by Mike Dearing, Development Principal at Sonoma Partners.

Alright, so you’ve finished customizing your organization and applying your company’s color palette to every nook and cranny of the application, but one task still remains – supporting your multi-lingual user base. While it may sound overwhelming, translating literally every string in your organization, keep in mind that you’re only responsible for any of the labels you and your team have put in place – Dynamics will handle everything that is native.

Below, I’ve broken down the types of translations that should be considered for your organization into 5 general categories.  But first, a few pre-requisites:

  • Ensure that you have the CRM System Administrator security role.
  • Change your language to the organization’s base language within your user settings.
    1

  • Install Excel or an Excel equivalent.

Native User Interface

This includes out of the box components such as native entity names, native field labels, native ribbon buttons, native sitemap tiles, etc.  Dynamics provides translations for their native UI which can be enabled through system settings.  While the base language of your organization is already enabled, if an additional language is desired it must first be provisioned for usage.  For Dynamics Online customers, this process is simplified, as all available language packs are pre-installed on your server.  For Dynamics On-Premise customers, you’ll need to download the language pack(s) that you’d like to provision from the Microsoft Download Center before completing the following steps.

  1. Navigate to Settings -> Administration -> Languages.
  2. Place a checkmark next to any additional languages to be provisioned (ex: Spanish).  Take note of the ‘Language Code’ column, as we’ll be using that throughout the other translation steps.
  3. Press ‘Apply’.
    2

  4. Read and accept the confirmation dialog.
    3

  5. The language will start provisioning.
    4

  6. You may close the dialog once the provisioning has completed.  Users may now select the language from their user settings.

Custom Entities & Fields

Native entities and fields will have been translated through provisioning of the corresponding language packs.  However, custom entities, custom fields, and any relabeling done for native fields will need to have translations applied.

  1. Navigate to Settings -> Solutions.
  2. On the solutions grid, if you haven’t done so already, go ahead and create a solution containing any custom entities and native entities that you’ve customized.  This will make our translation process quicker than trying to export translations from the default solution.
  3. From the solution grid, select your solution and then press ‘Export Translations’.
    5

  4. A dialog stating that this process may take several minutes will appear.  Press OK.
  5. A zip file called ‘CrmTranslations_<SolutionName>.zip’ will be downloaded.
  6. Extract the zip file.  You will be editing the file named CrmTranslations.xml.
  7. Open CrmTranslations.xml in Excel.  This workbook has 3 tabs: Information, Display Strings, and LocalizedLabels.  LocalizedLabels will be the tab where you’ll be doing your translations.  There will be a column per language pack provisioned.
    6

  8. You can ignore translating rows with an EntityName of Solution or Publisher.  You should also ignore translating rows with an Entityname of RibbonCustomization, as this will not be applied properly.  To translate ribbon buttons, see the “Custom Ribbon Buttons” step later.
  9. Once completed, save the translation file.
  10. If the file was extracted from the downloaded zip file, make sure to place the updated file back into the zip.
  11. Navigate to Settings -> Solutions.
  12. On the solutions grid, select your solution and then press ‘Import Translations’.
    7

  13. From the ‘Import Translated Text’ dialog, select the translation zip file, including your updated xml, and then press ‘Import’.
    8

  14. Once the process is completed, you may close the dialog.
  15. Publish all customizations.


Custom Sitemap Tiles

Only custom tiles with custom titles need translations.  Note that most tiles, even ones pointing to custom entities, will automatically translate based on other translations added to the environment in a prior step (see: “Custom Entities & Fields”).

  1. Navigate to Settings -> Solutions.
  2. Create an Unmanaged Solution with ONLY the Site Map in it.
  3. You can add the site map to this solution by clicking ‘Client Extensions’ from the left navigation and select Add Existing, Site Map.
    10

  4. Export the solution.
    9

  5. Within the solution zip, open the Customizations XML.
  6. Note the languages node at the bottom of the file.  It should include all of the provisioned languages within your organization.
    12

  7. For any custom title nodes, ensure there is a title node per locale id specified within the languages node.
  8. Save the XML file when finished.
  9. If the file was extracted from the downloaded zip file, make sure to place the updated file back into the zip.
  10. Navigate to Settings -> Solutions and import the solution zip back into CRM.
    13

  11. Publish all of the customizations.
    14

Custom Ribbon Buttons

Only custom ribbon buttons added to a ribbon need translations.  This includes the application ribbon as well, in case you’ve customized that.  Native ribbon buttons will translate through the provisioning of the associated language pack.

  1. Create an Unmanaged Solution containing all of the entities with custom ribbon buttons.  Note that if you have edited the application ribbon, you’ll want to add that by clicking ‘Client Extensions’ from the left navigation and select Add Existing, Application Ribbon.  In the example below I’ve included the native Quote entity. 
  2. Export the solution.
    15

  3. Within the solution zip, open the Customizations XML.
  4. Search for “<LocLabels>”.
  5. Each <LocLabel> node within the XML should have a <Titles> node nested within.  Inside of each <Titles> node is a <Title> node that specifies a string, as well as a language code.  Ensure that a title node exists per provisioned language.
    16

  6. Save the XML file when finished.
  7. If the file was extracted from the downloaded zip file, make sure to place the updated file back into the zip.
  8. Navigate to Settings -> Solutions and import the solution zip back into CRM.
    17

  9.  Publish all customizations.
    18

Custom Code

Custom HTML pages, javascript messages, and certain plugin messages should be translated as well.  There are various options here, but the two most common ones are:

  • Create a custom ‘Translation’ entity and add records within that entity to store a translation value, a translation key, and a locale id per language pack, per message to translate.
  • Create an xml web resource to store a translation value, a translation key, and a locale id per language pack, per message to translate.

Whichever path you choose, you can then retrieve those translations from your custom code as necessary based on the current user’s locale. Server-side, consider querying the usersettings entity for the uilanguageid and localeid. Client-side, consider leveraging the Xrm library’s Xrm.Page.context.getUserLcid().

And that’s it. While we may not excel in providing the translations themselves - though we do like to dabble in upside down question marks while buffing up on our ascii face art like so: (*¿*) - we do excel in helping you get your environment ready for them, so let us know how we can help!

Topics: Microsoft Dynamics CRM

Playing the Waiting Game

Today’s guest blogger is Melanie Waldman, a Consultant at Sonoma Partners

I was recently handed a functional spec and given the task of configuring a number of workflows. Flipping through the pages of documentation I found the following requirement.

Create a workflow that updates the opportunity priority rating.

If Status equals Open, Number of Tours is greater than 0, and Estimated Decision Date is less than 30 days from today, Set rating to A.

If Status equals Open, Likelihood to Win the Opportunity equals Very Likely, and Estimated Decision Date is more than 30 days but less than 60 days from today, Set rating to B.

If Status equals Open, Temperature equals Warm or Hot, and Estimated Decision Date is greater than 60 days away from today, Set rating to C.

As soon as I saw that all of the conditional statements involved a comparison to “Today’s date” I let out a heavy sigh. It feels like every customer I’ve ever worked with has a similar requirement and every time I open the process builder I can’t find the resources I need to fulfill their request.

We can do a lot through the use of Dynamic Values but for whatever reason Microsoft has not provided customers with a dynamic value for today’s date; so we built our own.

Using the calculated field functionality, I created a date field called Today. I set the formula to:

Today (date and time) = NOW().

After we created the field I had some reservations about whether or not the field value would update without a trigger such as opening the form, but the next morning when I checked my test records using Advanced Find, I found that all of the values in the Today field were current!

Now we had a dynamic today field that we could plug into a workflow to complete the customer’s requirement.

There is one caveat though, recalculation of the calculated field is a system process. So if you’re using the Today field on an entity with lots of records, keep in mind you’re kicking off a system job for each record, which could mean tying up a large number of resources every night at midnight. As long as resource allocation isn’t an issue for you, or until Microsoft provides us with a native dynamic value field that contains today’s date, this is a great alternative solution.

Topics: Microsoft Dynamics CRM Microsoft Dynamics CRM 2016

How Well Do You Delegate?

Today's post is written by Nick Costanzo, a Principal Consultant at Sonoma Partners.

We often hear from our clients that they need the ability to delegate visibility to records in CRM.

Unfortunately, Microsoft Dynamics does not have an out-of-the-box solution that can handle this.  Common requests include:

  • "I need to show my administrative assistant what I see."
  • "I need someone to keep an eye on my list of open activities when I'm out of the office."

There is a security privilege to Act on Behalf of Another User; but this is intended for server side code or integrations with other systems. In this blog, I’m going to provide a simple approach using native configurations to implement a Delegate Dashboard, which provides others with a view of your records so they can take action when needed.

  1. The first step is to create a self-referencing lookup field on the User entity called “Delegate.”  This is where users can select another colleague in the system to act as your delegate for a given period of time.  In this case, I’ll choose Connie as my delegate:

    1

  2. Next you can create 3-4 views that will be used in your delegate dashboard, and the filter criteria for these views will include the condition “Owning User Delegate = Current User”. In this case, I will create the following views:

    • Delegated Leads
    • Delegated Opportunities
    • Delegated Activities

      Here is an example for the Delegated leads view:

      2

  3.  Next, you can copy one of the existing dashboards in your system and title it, "Delegate Dashboard", or you can create a new one. Simply modify the charts and lists in this new dashboard to use the 3 new views we created above and publish the dashboard.

  4. From step 1, I’ve chosen Connie Watson as my delegate, so now Connie can see in a single dashboard the Opportunities, Leads and Activities that are owned by me. This eliminates the need for her to manually search in Advanced Find and run the risk of missing key records. *Note, if your organization has limited read/write access to these entities or the entities you’d like to include, you will need to share access as well.

    3

  5. This approach can also now be utilized on mobile devices in the Microsoft Dynamics Apps for Tablets and Phones, giving delegates mobile access to this dashboard:

    4

If your business requires more advanced delegation capabilities, we can always extend this framework to utilize record sharing, access teams, or custom development. The key is to understand who needs access to what data, and then we can help you build that out. Ultimately, you will be able to set a delegate and rest assured things will not get missed while you are away.

Topics: Microsoft Dynamics CRM

Inside Edition: How Sonoma Partners Uses CRM - Part 1

Today's post is written by Matt Weiler, a Principal Architect at Sonoma Partners.

Here at Sonoma Partners, we've been using Dynamics CRM to run our business since the heady days of CRM 1.0. Microsoft likes to call using the product you're selling "dogfooding", as in, eating your own dog food. We just think it's smart business.

Not only is Microsoft Dynamics CRM a good product that can work well for any business, but in working with the product ourselves, we know where it's strong and know where it might need a little bit of help. Developing for our internal system gives us practice identifying pain points in our business and thinking about how CRM can help make them go away. We don't want to just take orders, we want to really understand your business and make sure you're getting the most out of your CRM implementation.

We have a special name for our internal CRM; appropriately enough for a company named after a wine region, we call our CRM Grapevine (and we think you should brand CRM, too!).

As our business has grown and technology has changed, we've continually evaluated how we do what we do in Grapevine, and we've added, updated, and enhanced it appropriately.

One of the key benefits of CRM we've found is: you can get something basic up and running very quickly. Create a new entity, create some new fields, design some views and forms, create a process flow, a few processes, and some business logic rules to handle some simple validation, assign security, and boom, you're ready to start entering data. In many cases, that's all you'll ever need.

 

Think about it. If the data is entered in front of a computer, is fairly independent, and doesn't have a lot of relationships with other data; you may continue to use that setup for years to come.

 

But if this process is one of the core processes of our business, or if it becomes one of them over time, you'll soon discover that a completely out-of-the-box solution can no longer meet your needs.

Maybe it takes too long to fill out the form because there are a lot of lookups, maybe the data is commonly entered while on the road and the mobile app doesn't have a great interface for entering the data, or maybe the data needs to be combined with data from additional non-CRM sources to really give an overall view.

For any of these issues, the solution can be found in  simple updates in CRM, a new user interface, a new website, a new mobile app, or some combination of all those things.

In this series of blog posts, I'll be showing you some of the core processes at Sonoma Partners that live in or interact with Grapevine. In all the processes I'll be highlighting, we started with a very basic implementation and over time we enhanced it to make it easier, or to meet our changing business needs. For some of you working with or evaluating CRM, this may give you some ideas on how CRM can be used with your business; whether you're a professional services firm like us, or you work in any other industry.

I'm really hoping you'll get a little bit of the perspective that I've gained over my 9+ years of working with CRM: it's a living, evolving system, and based on your business, your clients, technology, and a host of other factors.

CRM needs to be analyzed continuously and updated to make sure it's doing what it's meant to do: make it easier to run your business.

How to get executives to pay attention to CRM

 

Topics: CRM Best Practices Microsoft Dynamics CRM

Dynamics CRM - Surfacing the Right Business Process Flow

Today's post is written by Trent Bell, a Principal Consultant at Sonoma Partners.

When Microsoft Dynamics CRM 2013 was released, it introduced business process flows for any entity including custom entities. Business process flows (BPF’s) can be a powerful piece of functionality to help guide end users through sequential processes without introducing too much rigor. With that said, it is important to know how to setup BPF’s to surface for the appropriate users. For this post, my screenshots are from a trial version of Dynamics CRM Online which should be equivalent to MS Dynamics CRM 2016 on-premises.

Important things to know about BPF’s:

  1. They must be activated
  2. They must be enabled for security roles
  3. They are part of an order of other processes on the same entity

Security Role Enablement

BPF’s can only surface to a user if the user has a security role that is enabled for that specific BPF.  This is pretty straight forward, but is critical to your overall BPF strategy if you happen to have many BPF’s per entity, and many security roles and/or user groups to manage.

An administrator enables security roles on a BPF by going into the configuration settings, choosing “Processes”, and then clicking into the relevant BPF process.

Once in the details of the BPF, one can enable the security roles via the button in the top navigation menu (see below).

Blog 1

In the “Enable Security Roles…” window, you will notice a couple radio buttons to toggle between “Enable for Everyone”, and “Enable only for the selected security roles”. As you might expect, choosing the first option will enable the BPF for all security roles. If you choose the second option, you will have to select the relevant security role(s) for which you would like the BPF enabled.

Blog 2

Order Process Flow

So, what if there are multiple BPF’s enabled for the same security role, or what if there are multiple security roles that have the same BPF enabled? 

For example, what if “User A” has security role “S1” and “S2” and “BPF1” in enabled for “S1” and “BPF2” is enabled for “S2”?  How will Dynamics CRM know which BPF to surface to “User A”?

The answer to this question lies with the “Order Process Flow” functionality. From any BPF, you can access and alter the “Order Process Flow” from the top menu (see screenshot below).

Blog 3

After clicking on it, the “Process Flow Order” is displayed, allowing a system administrator to re-order the relevant BPF’s by highlighting a BPF and using the green arrows. For example, if I want to move the “Opty Test 1” BPF down, I simply highlight it and use the down arrow to move it (as seen in the below screenshots).

Blog 4

Blog 5

Now that we have re-ordered our BPF’s, what did that do and why is it important?  The BPF that is listed first will be the default BPF to be surfaced/used when our situation with “User A” takes place. It is also important to note that this will be the BPF used when creating a new record as well.

Switch Process

Another feature to note that is related to the topic of business process flows in Dynamics CRM is the “Switch Process” button. This button will appear when viewing a record by a user who is able to see multiple BPF’s for that entity. This user can click on the “Switch Process” button and choose to apply a different process to the record (note: only one BPF can be applied to a specific record).

Blog 6

Blog 7

Whenever someone switches processes, the current process stage will be set to the first stage of the newly applied BPF.

When creating a NEW Opportunity, the user does NOT have the ability to switch processes (BPF’s) until the record is saved for the first time.  As you can see from the screenshot below, the menu option to “Switch Process” does not exist. 

Blog 8

As briefly mentioned above, this means you only have one way to dictate which BPF surface, and this is by the “Process Flow Order”.

In summary, business process flows are a powerful piece of functionality provided by Microsoft Dynamics CRM, and should be configured with some forethought into all user groups who might touch that relevant entity.  If need be, Sonoma Partners can help you work through this as part of your overall CRM solution strategy. Contact us to learn more.

Dynabacus the Microsoft Dynamics CRM Record Count Tool

Topics: Microsoft Dynamics CRM Microsoft Dynamics CRM 2016

FetchXML: Left Outer Joins with Multiple On Clauses

Having worked on CRM for ten years, I thought I understood everything that was possible with FetchXML. After all it seems pretty straight forward and each clause has almost a one to one equivalent with SQL. However, while I was recently doing some work on a project that required me to find records missing certain child records, I was surprised to find my understanding of left outer joins was incomplete.

The Requirement

In the project I was working on, we were using the native Connection entity to track relationships between contacts and users. Some of the Connections were manually created, but others needed to be automatically created based on business logic. In some cases we needed to detect all contacts that a user did not have a connection of a specified role with.  This seemed like a good case for using a left outer join and I sat down and wrote the following FetchXML:

The Concern

As I reviewed the FetchXML, I became concerned that I wouldn’t get the proper results with this query. I was assuming that CRM only used the to and from attributes on the link-entity element to build the on clause for the left join in SQL.  I knew that if the additional conditions inside the link-entity were added to the SQL where clause, that I would get no rows back.  In short, I was worried the generated SQL would look something like this:

It was enough of a concern that I decided to fire up SQL Profiler on my local dev org and see what exactly CRM generates in this case.  Much to my surprise I found the following (slightly cleaned up to help legibility):

In Summary

So in the end, CRM came through and put the link-entity’s conditions in the on clause for the left join.  This subtle change makes a huge difference in the results returned and makes left joins much more useful in CRM than one might assume based on the FetchXML structure.  This left me with an efficient query to solve the business requirement and a new found respect for FetchXML.

Topics: Microsoft Dynamics CRM Microsoft Dynamics CRM 2013 Microsoft Dynamics CRM 2015 Microsoft Dynamics CRM 2016 Microsoft Dynamics CRM Online

Performance Considerations Creating Custom Reports in Dynamics CRM - Part 1

Today's post is written by Rob Jasinski, Database Architect and DBA at Sonoma Partners.

The ability to create custom SSRS reports for Dynamics On-Premise is a very powerful feature and adds a lot of flexibility to CRM’s reporting ability.

However, with that power and flexibility comes the potential to create reports that can run slow, are inefficient, and in worst cases, actually affect the performance of CRM as a whole. This article will focus on some things to watch out for when creating custom SSRS reports for Dynamics CRM On-Premise. Part 2 in this series will focus on Dynamics CRM On-Line.

Use the numeric value for option set values

For option sets in CRM, filtered views return 2 values; the integer value and the name value. For example, StateCode and StateCodeName from FilteredAccount. When filtering by these values, consider using the integer value rather than the name. The integer value is stored directly in the entity table whereas the name value is derived from the stringmap table. In most cases, the numeric value is also indexed and since it’s on the primary table, will perform much better than referencing the derived name.

select name, statecodename from FilteredAccount where statecode = 0

Filtering by date

Use the “utc” version of the date field when filtering by date. Every date field in the CRM filtered views returns 2 fields. For example, actualstart on FilteredAppointment is returned as actualstart and actualstartutc. The actualstart field is actually a calculated field that converts the date to the running user’s local time zone, whereas the actualstartutc field is the raw UTC date retrieved directly from the database table. Since the “utc” version is the actual field in the table, it will leverage any table indexes and perform significantly faster in most cases.

select subject, actualstart from FilteredAppointment where actualstartutc >= '1/1/2015’

Consider using nolock

Whenever data is queried from the database, SQL Server internally manages locks on that query. In a report query that takes a significant time to run, it can prevent the data being updated from other users causing CRM to appear to lock up for other users. One solution is to use the “nolock” query hint. This tells SQL Server to not manage locks for this query, thereby not blocking access to other users who need to change the data. Keep in mind, this also allows “dirty reads”, in that there is a possibility that either the data has changed since the query first started or the original data read is no longer valid. When returning financial or other sensitive data, nolock should not be used. But for non-sensitive reports (i.e. list of open activities, list of accounts, aging reports, etc.), this can help maintain CRM usability and make CRM less susceptible to poor query performance.

select name, accountnumber from FilteredAccount(nolock)

Use Union All versus Union

In more complex reporting queries, you may find the need to union several result sets together to get the data needed for the report. If the result sets will not have any duplicate data across each set, use “Union All” which essentially just concatenates each result set and returns it directly to the report. However “Union” actually collects all the results first, sorts them, then removes any duplicates before returning the results to the report. This can be very time consuming when returning a large number of results.

Avoid “Select *”

Only return the fields the report needs and never use “Select *” when returning data from reports. There are many calculated fields returned from filtered views, from dates converting to local times and currencies converting to local currency. And if these fields are not required for the report, it will still make the calculation for every one of these fields for every row returned. This will take up server resources and cause the query to return data much more slowly. Also, only specifying the fields needed will reduce the amount of network traffic and make the results get back to the report much quicker.

Primary attribute values

Don’t forget that primary attribute values (usually [customprefix]_name) for most lookups are already included in the primary filtered view for the entity being queried. For example, for FilteredContact, the attribute AccountID is a lookup to Contact. The primary attribute on Contact is Name. So the filtered view, FilteredContact, also has a field called AccountIDName, which is the Name value from the associated Contact record. There is no need to join FilteredAccount into the query unless you need additional information outside of the primary attribute.

select FullName, AccountIdName from FilteredContact

Versus

select FullName, Account.Name

from

      FilteredContact Contact

      join FilteredAccount Account on Contact.AccountId = Account.AccountID

If you have any questions about creating custom SSRS reports for Dynamics CRM On-Premise, please contact us

Dynabacus the Microsoft Dynamics CRM Record Count Tool

Topics: Microsoft Dynamics CRM