Solved

Filter dropdown on result other dropdown

  • 19 January 2021
  • 2 replies
  • 245 views

Userlevel 1
Badge

Hi,

 

Is it possible to filter a dropdown (lookup) on a result from another dropdown in the same form?

 

I have a form for a ticket. On this form I have a dropdown with departments. When I choose a department, I would like to filter the next dropdown with employees for the selected department.

 

When I use a reference with department_id and employee_id, then the dropdown depends too much on the departments. I want to have a dropdown with all employees if I don’t select a department.

 

Is this possible with a reference, filter, view?

Can anyone help me?

icon

Best answer by Erwin Ekkel 19 January 2021, 15:08

View original

This topic has been closed for comments

2 replies

Userlevel 6
Badge +16

You could do the following: 

Create a view of the employee table that also has a placeholder value that holds all records something like this: 

Select department_id,employee_id, [other columns] from employee --original data
union all
Select -1,employee_id, [other columns] from employee -- placeholder show all rows

Then make an expression column on the table where you want to show these columns in the form. The expression column uses an isnull with a replace to the placeholder value (-1):   isnull(department_id,-1).

Then create two references:
a reference on the expression column and the employee_id to the view. 
a reference on department_id = department_id on the original table for the lookup. 
 

Userlevel 1
Badge

Thanks! It works. This answer helped me a lot