Multilevel departments

Multilevel departments


I have here something new... can anyone help me?
I created a Company Department Entity, and there are all the departments in it. There are 3 departement levels, i.e., the departments of 3rd level are grouped in 2nd level dept, and 2nd level dept are group in 1st level dept.

I'm trying to create a list of all the departments, and the employees in all them. That is, selecting one of the first level departments, the list should show all 2nd level and 3rd level department employees.

I attached the sample oml where I'm trying so.

How can I read the first level dept, then recursively read the next levels departments? There can be 3 levels or more, however in this example there are only 3.

Thank you for any help.

Fernando Dias
Hi Fernando,
if you add two fields to your department entity it might do the trick:
- RootDepartment (Department identifier)
- DeepnessLevel (integer)

The RootDepartment should point to the top level department which is it's hierarchic superior.
The DeepnessLevel should help order nodes in a hierarchic way (ex: 1 for the the top level, 2 for the next, ...).
So, if you select one the first level departments, you can immediatly know all departments that are below it and their order. This and the ParentId should suffice to build a department tree.
Check out 'Expand and Collapse behaviors in a Web page' sample in Advanced Samples at the extranet :)

You can also use the entity as is in your eSpace and use the action I added to it (Department_GetChildren). It returns the department and all of its childrens. You can test it using the screen Hierarchy.

Hope it helps,

Cláudia Macedo
Thanks Claudia

Your solution is great!

Thanks Nuno

That works but still I have the problem to read all the levels... But Claudia solution gives all the answer.