If you have a situation where you must have one lookup offer only a limited set of values based on what is selected in another lookup, then you must setup lookups with dependencies on one another. This article explains how to do that.

Let's pretend we have a need to track an opportunity to sell a car. In this case you might want to have the car make and model recorded on the opportunity. Since there is the possibility of selling multiple makes and models, we want to have the user select the Make of the car and then the list of Models should be displayed based on the selected Make.

First use the page designer (View->Open page designer menu) and create the two lookup fields - Make and Model

Then, put them on the Opportunity screen in the appropriate place and you should see the fields show up and working. If you decide to put in the values for Makes and Models at this point, you will notice that all Models show up no matter what Make is selected. So, the next step is to go to the object in the system designer and add the Make field to the Model object.

Once this is done, publish your changes and the Model lookup should now have the ability to link each Model to a specific Make. If you haven’t already, populate the values in the lookup for Make.

Then, when you populate the lookup values for Models, you will have a new field that enables you to select the Make that each Model applies to.

The final step is to tell your Opportunity screen to filter the Models whenever a user changes the value of the Make field. This can be done via a Business Rule in the page designer.

Once all the changes are saved. Refresh your screen and you should see that selecting the Make automatically makes the Model values get filtered down to only those that apply to the specific Make of the car selected.

Bonus Tip: You will notice that once you select a Model and then go back and change the Make, the previous Model selection still stays around, but you may want the Model value to be cleared so that the user knows to reselect the Model based on the newly selected Make. For this, a tiny bit of code is needed to make sure the old value is cleared out. Add the highlighted code below to add the autocomplete and autoclean settings which will clear out the Model selection when a new Make value is selected.

Posted in: