Filter Lookup Options with filterForDropdown
Example scenario
You are creating a Deal and selecting a Customer from a lookup field.
After selecting the customer, you want to show only related records in other lookup fields, such as Communication or Deals.
For example, when a customer is selected, the Communication lookup should show only communication records linked to that customer.
Using filterForDropdown
doo.model.<field>.filterForDropdown allows you to filter available options in a Dropdown or Lookup field.
The filter can be based on another field value, user role, or record context.
Example: Filter lookup fields by selected customer
if (doo.model.customer.value) {
doo.model.communication.filterForDropdown =
`customer.title === ${doo.model.customer.value.title}`; // title from linked customer
doo.model.deals.filterForDropdown =
`customer.title === ${doo.model.customer.value.title}`; // title from linked customer
}You can also write the same logic using string concatenation:
if (doo.model.customer.value) {
doo.model.communication.filterForDropdown =
'customer.title === ' + doo.model.customer.value.title; // title from linked customer
doo.model.deals.filterForDropdown =
'customer.title === ' + doo.model.customer.value.title; // title from linked customer
}
How it works
doo.model.customer.value
represents the selected customer in the lookup field.
doo.model.customer.value.title
reads the title of the currently selected customer.
doo.model.communication.filterForDropdown
filters the available records in the Communication lookup field.
doo.model.deals.filterForDropdown
filters the available records in the Deals lookup field.
customer.title
means the title field from the linked customer record in the filtered records.
customer.title === ${doo.model.customer.value.title}
shows only records where the linked customer title matches the selected customer title.
Example: Filter account numbers by selected currency
In this example, the Account Number lookup is filtered by the selected Currency value.
if (doo.model.currency.value) {
doo.model.accountNumber.filterForDropdown =
`currency === ${doo.model.currency.value}`;
}
If the account list is loaded from data and only one account is available, you can automatically select it and still apply the filter:
doo.model.accountNumber.filterForDropdown = `currency === ${doo.model.currency.value}`;
doo.model.accountNumber.setValue( myCompanyAccounts.data.length === 1 ? myCompanyAccounts.data[0].id : null);Example: Filter dropdown by user role
if (doo.currentUser.roles.includes('Admin')) {
doo.model.state.filterForDropdown = ['Active', 'Closed'];
} else {
doo.model.state.filterForDropdown = ['New'];
}
In this example, Admin users can select Active or Closed, while other users can select only New.
Example: Filter lookup using multiple conditions
doo.model.members.filterForDropdown =
"branch === A01 or branch === B01";This shows only members from branch A01 or branch B01.
Example: Filter lookup by text
doo.model.cities.filterForDropdown =
"city contains Pra";This shows only cities where the city field contains Pra.
Example: Filter multichoice values
doo.model.tasks.filterForDropdown =
"state in [New, Canceled]";This shows only tasks where the state is New or Canceled.
Result
When the user selects a value in one field, another Dropdown or Lookup field automatically shows only relevant options.
This helps users choose valid related records and prevents them from selecting unrelated values.