Assume there are three entities, as it is shown on Screen 1. The relations between those entities are displayed on Screens 2 and 3. Let’s create a cascading (master detail) lookup.

Microsoft Dynamics CRM

Screen 1

В Microsoft Dynamics CRM

Screen 2

В Cascading Lookup in Microsoft Dynamics CRM

Screen 3

В Create Cascading Lookup in Microsoft Dynamics CRM

Screen 4

City lookup should be configured to show only the cities that are relevant to selected Country lookup value in the Addresses entity. Open the city field properties dialog in the form (See Screen 5).

To do that:

  1. Open the desired solution.
  2. Select Addresses entity Г  Forms
  3. Open default form
  4. Select City Lookup
  5. Click on Change Properties button

В How to create Cascading Lookup in Microsoft Dynamics CRM

Screen 5

As a result, the window displayed on Screen 6 appears. Dialog menu options can be modified to display only the relevant data (See Screen 6).

В Cascading Lookup

Screen 6

Now “City” displays the relevant data only. Still, there is a possibility to select a city and then a country not relevant to it. This may lead to non-synchronized data (Addresses Г  Country and Cities Г  Country). In this case the incorrect data will be displayed to a user. But if the field is used in the business logic, it may cause even more troubles. To resolve this issue, validation of input data can be implemented on the SERVER side.

В How to solve synchronization issue with GUI

Add JavaScript to disable and reset City Lookup when the user changes Country.

//CascadingLookUp.js

function CascadingLookUpSample_Init() {

Xrm.Page.getControl(“ut_city”).setDisabled(crmForm.all.ut_country.DataValue == null);

}

function CascadingLookUpSample_CantryOnChange() {

crmForm.all.ut_city.DataValue = null;

Xrm.Page.getControl(“ut_city”).setDisabled(crmForm.all.ut_country.DataValue == null);

}

Now bind events to the abovementioned functions. (See Screen 7, 8)

To bind CascadingLookUpSample_Init() on the form load event:

  1. Open the form
  2. Click on Form Properties ribbon button
  3. Select Events tab in Form Properties dialog
  4. Add library to the libraries section, if it wasn’t done earlier
  5. Select OnLoad event from dropdown and click the Add button placed in Event Handlers section
  6. Set up library and handler function name in Handler Properties dialog

В How to create Cascading Lookup in Microsoft Dynamics CRM

 

Screen 7

To bind CascadingLookUpSample_CantryOnChange() to Country Lookup’s on change event:

  1. Select Country Lookup in the form
  2. Click on Change property ribbon button
  3. Select Event tab in Field Properties dialog
  4. Set up Library to CascadingLookUp and Function to CascadingLookUpSample_CantryOnChange

 

В Cascading Lookup in Microsoft CRM

В  Screen 8

В How to Add Custom View

В Create Cascading Lookup - CRM

Insert math as
Block
Inline
Additional settings
Formula color
Text color
#333333
Type math using LaTeX
Preview
\({}\)
Nothing to preview
Insert