Tip #30: Use ConnectionDialog for easy connection to CRM

If you’re writing Windows Forms or WPF application that needs to connect to a number of Dynamics CRM organizations on ad-hoc basis, e.g. custom tool, then try using ConnectionDialog class instead of home-grown connection code. It is very surprising how little attention receive CRM Developers Extensions in general and a little obscure but very handy ConnectionDialog class, in particular. With the help of this class (that has even its own “dedicated” namespace Microsoft.Xrm.Client.Windows.Controls.ConnectionDialog), the usually verbose boilerplate connection code can be reduced to the following:

   ConnectionDialog cd = new ConnectionDialog();

   bool? connected = cd.ShowDialog();

   if (connected.GetValueOrDefault(false))
      using (OrganizationService service =
         new OrganizationService(
         // use CRM organization service
         WhoAmIResponse response =
                         new WhoAmIRequest());

Tip #29: Solve missing permission issues

Sometimes, especially when you upgrade CRM or you add new entities, one of your users may see an error message like this:

The principal user (xxxxxxxx) is missing permission prvXXXXXXX

This error means that the user’s security role is missing a permission required for the object they are trying to view or the action they are trying to do. In this example, the user is missing prvReadComplexControl. From this we can gather that it is a privilege (prv) and it is a read privilege (“Read”), but what is “Complex Control?” When I look at security roles, I don’t see anything with the name “Complex Control.”

The answer can be found in this section of the Software Development Kit (SDK). Simply search on the page for the privilege in the error message, and you will see that the prvReadComplexControl privilege is read permission to the Process Configuration entity on the “Customization” form of security roles.

Note – the link referenced in this post points to the CRM 2011 SDK. The 2013 SDK is available to be downloaded here.

Tip #28: Beware of autosave in your scripts

CRM 2013 introduced autosave feature that, depending on a specific scenario, could be really helpful. There is also ability to switch autosave off across the organization using Administrator > System Settings dialog. Unfortunately, this flag only controls form behavior when user explicitly edits the record. The record will still be saved if user navigates away using, for example, browser’s back button. In this case, if your form has onload script that modifies the content, the changes applied by the script will be saved whether user intended it or not. This could be completely unexpected and needs to be handled with caution. It is possible to better manage autosave behavior but it does involve a bit more than a simple checkbox. Hopefully, future CRM updates will add some granularity to the autosave settings so that it can be truly switched off, when needed, without any side-effects.

Tip #27: Conditional action in dialog based on record counts

One of the more powerful things that can be done with a dialog is querying data. You can query data in CRM to populate a picklist, and my favorite use of it is to query data and then base a conditional action on the record count.

Consider this scenario: You sell to businesses, you have a dialog to create an opportunity, and you want it to act differently for existing customers than for new customers.

  1. Create a dialog that runs from the account entity
  2. Add a query CRM step and build a fetch to query sales orders for the selected account. See this post for detailed instructions on how the query step works.
  3. Add a check condition step. Select the name of your query step and select “records” and “less than one.”

This gives us the ability to dynamically query CRM data and conditionally do something .

Tip #26: Self-service for CRM users

One of the most valuable input channels for CRM customizers and developers is direct feedback from the users. The problem is that average user is either too reluctant or too busy to spend time on feedback and that pretty much rules out third-party systems like getsatisfaction, uservoice, etc, however useful and clever they might be. By the time user logs into the system of their choice, the context could be long forgotten and entering the suggestion becomes a painful trip down the memory lane.

Create a custom entity named, say, Suggestion or Feedback and add fields to capture the required information. Then add a workflow that simply emails the content of each newly created record to CRM suggestions or support mailbox. Now users can enter their feedback and suggestions when and where required without leaving CRM system.

Read more about enhancing the system

Tip #25: Make bit fields required in Business Process Flows

In the new Business Process Flow functionality in CRM 2013, what if you want to have a bit field that must equal yes before the user can advance to the next process stage? When you add a new bit (two option) field with the default values and make it required, when the record is viewed, the value of the field on the process flow will be set to no, but the user will still be able to move past the stage, because it will appear to CRM to contain a value (even though that value is no).

The answer is to change the options in the bit field to “Complete” and “Mark Complete (instead of “Yes” and “No”). If those values are present and the field is required, the business process flow will require the value to be “Complete” before proceeding.

The answer is that you need to click the “required” box on the process flow step, rather than set the requirement on the field definition in customization. If the field is required in customization, it will need to contain data, but it will treat “No” as a value, and allow the user to proceed to the next step. If the “required” checkbox is checked on the business process flow step, the process flow will not let users proceed to the next step without setting the value to 1 (yes).

Thanks to Adam Vero for helping make this tip correct. Check out his blog at http://blog.crmguru.co.uk/ for some great tips.

Tip #24: Use children to update running workflow

Running workflows always cache the definitions and are unaffected by any future definition changes. This behavior is by design, however, occasionally it’s desirable to have some of the steps to use the latest definitions, e.g. content of the email. Isolating these steps into a separate child workflow effectively allows users to modify properties of a running workflow.

Let’s say you have a requirement to send an appointment reminder to a customer one day before the scheduled service activity is due. Typical implementation would like this:

Service Activity Reminder workflow

The problem is, as soon as the workflow starts (triggered by a service activity record creation), it will be in the waiting state until the time is due. So if you decide to change the email content (to fix a spelling mistake, for example), reminders for the existing appointments will still use the old definition even though the reminders themselves could be in the future.

Solution is to isolate sending email into a child workflow:

Service Activity Reminder with Child workflow

In this implementation, email reminders will always use the latest definitions from the Send reminder workflow because it does not actually run until the time is due.

Tip #23: Swap Customer Addresses

In Microsoft Dynamics CRM, the contact and account entity form display the first two addresses for the customer, and by default, addresses 3 and greater are displayed in the address link on the navigation bar (AKA more addresses).

Consider this scenario: you are a wealth management company, and some of your clients are retired “snowbirds” that spend the winter in Florida and the spring and summer in the north. How can you make it easy to swap addresses so another address appears as address 1 part of the year?

  1.  Edit the Address entity “Associated” view. Remove the filter that makes this view only show addresses greater than Address 2. This will now make the navbar link for addresses display all addresses, including the addresses on the form.filter
  2. Add the Address Number field the Address form.
  3. Now you can go to a customer record, click on the address NavBar link, open the addresses, and manually update the address numbers. I recommend updating 1 to a higher number, then updating the address you wish to be address 1 to address number 1.

Address swaps can also be automated using workflow or other processes.

Tip #22: Install Dynamics CRM with precreated database

In some enterprises, database administrators wish to have greater control over the database creation process for CRM installations. This can be for security reasons, naming databases a certain structure, or controlling how the database files are structured. The CRM implementation guide does not include a pre-created database option, but it is possible to do in a supported way.

  1. In a development or non-production environment, create a new CRM organization.  It does not matter what you name it.
  2. Back up the organization (*_MSCRM) database
  3. Restore to your production SQL server with the desired name (be sure it ends in “_MSCRM”)
  4. Install Microsoft Dynamics CRM server. When you reach the screen that asks what roles to install, instead of installing full server, uncheck one of the roles (like a minor one, like help server). If you don’t install all the roles, the organization will not be created during the installation. You can come back and install this role when you are finished.
  5. When the installation is complete, launch the deployment manager and import the organization from the backup you restored in step 3.

Tip #21: Don’t work too hard

Happy Thanksgiving

To all our American friends, acquaintances, regular listeners and accidental visitors we wish Happy Thanksgiving.

Don’t work too hard and remember to spend time with your loved ones.

Our professional harvest this year includes formidable CRM 2013, let the next year see this game changer thriving and taking over the world.

CRM Tipsters