Restricting records for lookup fields

For certain configurations of relationships, you can restrict the available records for a lookup field based on other related records using the Main Lookup and Link Lookup properties of a lookup field. These properties are only available when an object has relationships to at least two objects that are also related to each other. For example, suppose your application has Country, State, and Company objects with the following relationships:

  • The relationship between Country and State is one-to-many.
  • The relationship between Country and Company is one-to-many.
  • The relationship between State and Company is one-to-many.
If a company has a related country, the states available to that company should be restricted to that country's states. You can enforce that restriction using the Main Lookup and Link Lookup properties of the lookup field that represents the relationship from Company to State.

Objects and Relationships

In this example, the Company object's lookup field State has the following properties:

Main Lookup and Link Lookup Properties

The Main Lookup property specifies that the company's related country limits the choices for the lookup field.

The Link Lookup property specifies that the State lookup field will be restricted to the country's related states.

The following example illustrates how the Company's State lookup field is restricted.

The application contains two countries:

All Countries

The country Canada has four states:

Country and States

The country United States has five states:

Country and States

After setting a company's country, its State lookup field is filtered to show only that country's states:

Select State

You can also restrict the records for a lookup field using the client-side API rbf_setLookupFilter().