Cascading LOV is a common requirement. It is dependencies of an LOV on the selected value of another LOV. In this post, I will explain how cascade LOV can be implemented in a search criteria form.
Use Case:
Searching all the employees reporting to a manager in a department. For this, cascading LOV has to be used to define the dependencies between departments and the list of all employees in that department. i.e one LOV on DepartmentId and another LOV on ManagerId to retrieve all the employees in the selected DepartmentId LOV.
Steps:
1. Create Read Only view Objects on Employees, Departments table. (hr schema is used)
Say EmployeesVO and DepartmentsVO
2. Define a view criteria (findByDepartmentId) in EmployeesVO to filter all the employees based on a DepartmentId.
3. Add DepartmentsVO and EmployeesVO as view accessors to EmployeesVO. In the added Employees view accessor, shuttle the view criteria(created in step #2) to the right. Provide the value for the bind variable as DepartmentId.
4. Define LOV's on DepartmentId (wrt Departments view accessor) and ManagerId (wrt Employees view accessor). Once a Department is selected in Department LOV, DepartmentId attribute will hold the value of selected department. This selected value is passed to the findByDepartmentId view criteria as defined in the above steps.
4. Define LOV's on DepartmentId (wrt Departments view accessor) and ManagerId (wrt Employees view accessor). Once a Department is selected in Department LOV, DepartmentId attribute will hold the value of selected department. This selected value is passed to the findByDepartmentId view criteria as defined in the above steps.
5. Define a view criteria (findByDepartmentMgrId) in EmployeesVO, which will be dragged and dropped as a query component on jspx page.
6. In the view controller project, create a jspx page. Drag the view criteria defined in the above step as query component.
7. Run the jspx page. Dept Id LOV will show all the departments, while Mgr Id LOV will show all the employees for the selected Department. After selecting the Dept Id and Mgr Id values, click on Search button. The resultant table will show all the employees reporting to the selected manager of the selected department.
Sample Workspace:
Download the sample workspace from here.
Hi,
ReplyDeleteThanks for the wonder full post, it really help me, but my use case is to have 3 cascading filters, which unfortunately I cannot make it to work by this method.
Do you know by chance the reason ?
Regards,
Cipi
Hi Cipi,
DeleteWhat is the issue you are facing?
Rgds,
Umesh
I am able to implement 3 cascading LOV's in search criteria.
DeleteHi,I follow your steps,but I cannot make it to work, when I select Department, the MgrId cannot change, please help me
ReplyDeleteI have found my problem, thank you
ReplyDeleteWhat was your problem? I think I am facing the same.
DeleteCan you please post the issue you are facing?
DeleteGot the same problem and solved it by adding dependency to target attribute that should auto change LOV values based on another attribute.
Delete1. goto VO Attributes
2. double click on the attribute name Edit Attribute
3. On popup left hand menus click on Dependencies
2. Shuttle source attribute name that current attribute is dependent on
Hi Umesh,
ReplyDeleteThe above example is working fine when two VOs i.e, EmployeesVO and DepartmentVO are used. In particular criteria defined wrt EMployeesVO is created as query panel.
Could you plz suggest how to achieve the below scenario where we use three VO's
two VO's for selectOnechoice and one VO to build query panel.
Eg: department id populated by Departments VO
Location id poplated by LocationsVO and dependent on Department id.
EmployessVO is used to build criteria and display all employeess having departid and location id.
Thanks in advance.
Regards,
Naren.
Hi Narender,
DeleteThis example works fine with three VO's as well. I implemented the same use case as you mentioned.
The dependencies is as :
LocationId-->DepartmentId-->ManagerId
You can have a look at my work space at: https://dl.dropboxusercontent.com/u/107714024/SearchForm.rar
Please let me know if you have any issues.
Thanks,
Umesh
Hi Umesh i want to know how to implement this in table filter Cascading LOV,please help
ReplyDeleteHi Nada, What do you mean by implementing cascading LOV in table filter.
DeleteThanks,
Umesh
Hi Umesh, i want to know how to implement this if i have between operator , from department , to department ,please help
ReplyDeleteHi Asmaa,
DeleteCan you please explain a little more about your use case.
What if department id is not part of the form. Instead department name configured as lov..
ReplyDeleteStill you can configure using the same concept, as long as your foreign key relationship is maintained.
DeletePlease let me know in case you have any doubts.