Filtering Picklists in Microsoft CRM 2011 Dialogs

Visit Website View Our Posts

We have had several posts on the Customer Effective blog covering the process dialog capabilities of Microsoft Dynamics CRM 2011. In case you haven’t heard, dialogs provide a prompt and response wizard that can be used to capture user input and streamline creation of new records.

In a recent example, I wanted to create a dialog for quick case entry. The case form in Microsoft Dynamics CRM contains many fields, and it can sometimes be overwhelming for creation of simple cases. In this scenario, we want a quick entry form. Dialogs are perfect for this—we can create a dialog with just the questions that need to be answered to create a case, and then use the responses to create the case.

In this post I’m going to assume that you have a basic understanding of how dialogs work. If you don’t, I recommend the series of introductory posts on the CRM Team Blog.

In my case dialog, I want the user to select an account, then have a picklist of contacts related to the selected account. When you look at the dialog wizard, it is not immediately obvious how to filter a picklist based on a value selected in an earlier picklist. Here are the things that you need to keep in mind:

1. Timing is important—you can’t call a value before it is defined

When I started defining the dialog, I first created the step to query the crm database for accounts, and then I tried to add the step to query the crm database for contacts, but it would not let me filter the contacts to the account query step.

I realized after pulling my hair out for a while, that the query step does not select a specific record, but rather provides the logic to populate the picklist of values, and the prompt-response step selects the value.

2. You have to first add the prompt response step, then add the query step filtered by the value selected.

I realized that I needed to insert a prompt response step first, asking the user to select an account, and then I could enter a query step and filter it by the value selected in the first prompt response. It looked like this:

Step 1: Query step


Step 2: Insert page with Prompt Response asking to select account based on the query defined in step 1


Step 3: Query step for contacts. In the advanced find query select Parent customer equals xyz. Go to the Modify Query Variables tab and select the variable1 field. Using the form assistant on the right, select the name of the second step in the "look for" menu and select the account field—this will dynamically filter this query to records related to the account selectedimage

Step 4: Add prompt response to select contact based on the query created in step 3.


Once my steps were in the correct order, my picklist for contacts was filtered correctly. This is very powerful—using this approach, you could have a picklist filtered by multiple criteria. You can call the results of a prompt-response step multiple times, so that one picklist could also be used to filter additional picklists.

4. Dependent picklists cannot be located on the same wizard page

This may go without saying; but in the above example, since you can’t insert a query step while inside of a page in the dialog wizard, you will need to place dependent questions on a page of the dialog other than the page where the primary question is located. I can’t build my filtered query of contacts until the account has been selected in the prompt-response step, so I need to insert the first page, then insert my second query, then insert another page, where I can prompt for the contact.

As a best practice, I would recommend structuring your dialogs so that other questions are included on the first page, such as the subject or description, otherwise the dialog pages may look uneven with one question on the first page and multiple questions on the second.

 Post by: Joel Lindstrom, Customer Effective

2 thoughts on “Filtering Picklists in Microsoft CRM 2011 Dialogs”

  1. Joel, this is all great if the field you are filtering on is on the main entity and is a look up into another entity. What if the filtering needs to be done across a link between two entities? For example, between Account and Contract, an Account can have many contracts. I can set up the required advanced find query to return my data data, I can even set up the required query in the dialog, but when I go to set the filter variable 'Modify Query Variables' tab, I do not get a variable that will dynamically allow me to set the Account when the primary entity of the query is Contract. Instead I see the GUID, used in the setting up of the query, located inside the Fetch XML and not a variable that can be replaced by subsequent code.

    Is there a way to make this happen? I am under the impression that all the dialog is doing, when it comes to filtering the data, is taking the generated Fetch XML, using the selected filter value, and then doing a replace against the XML string to replace the word 'Variable1' with the value indicated in Variable1 below. If this is the case then why does it matter if the query field all belong to a single entity of if the query crossed a link between two entities and needs to apply the filter against a value in the other side of the link.

    1. Kyle,

      You should be able to do this without making your fetch span entities. For example, you can build your queries exclusively in the contract entity. Do contracts where customer equals (pick a company), then that should give you a variable you can replace with the customer ID reference.

Comments are closed.

Show Buttons
Hide Buttons