Parent Child Departments - Member of

eddy42
Tera Expert

Our organisation has quite a complex structure (as I imagine many do) in that there are a lot of department levels.

e.g.

Directors

-- Business Services

---- ICT

------ Operations

-------- Service Desk

-------- Field Engineering

-------- Systems

------ Development

-------- Systems

Some areas of the business go to only 2 levels and some go up to 9 levels.

I have mocked up using the parent field on cmn_department in our dev environment and my integration from the external HR system (which feeds in flat file) carefully builds the structure so that you can open a department and see a parent field and a related list of child departments - great.

That is until I need to know who (for example) is a member of Business Services (e.g. for a report or for user critera on the portal) - it would need to include everyone who is in the child departments of Business Services.   I see this as being a bit like roles in ServiceNow but they seem to use a complex inheriting method and this surely is overkill for this.

I thought it may be doable via a dynamic filter (using a script include to add all child group members to an array and returning that) but I can't see any way to get a dynamic filter to use a sepcified field (i.e. pick User isAMemberOfDepartment Business Services) where isAMemberOfDepartment is my script include and business services is picked by the user.

I really don't want to have to add 9 fields to the user form in case they are needed as this will require reporting based on fields like DeptLevel1, DeptLevel2, DeptLevel3 etc.

Has anyone had to model a hierarchical structure like this and if so how did you get around these issues?

9 REPLIES 9

LaurentChicoine
Tera Guru

Hi Paul,



You won't be able to do it with dynamic filter as it does not allow to pass a parameter. You will have to use a filter User is javascript: isMemberOfDepartment('name or sys_id orf the department')



The script include will have to be client callable (your user need to have the read ACL for the table used) and have to return an array with the list of all users in that department.



You could also have a filter like User.Department is javascript: childDepartmentsOf('name or sys_id of department')



I recommend building your functions for using sys_id only to avoid having a dependency on the department name.



As for using field like Business Service, I think you can use current inside the javascript part, as I see exemple in OOTB Refeference qualitfier, but I've never used it myself.


Thanks - this is what I suspected, unfortunately this will mean no-one will be able to write reports based on department other than a developer and as department is one of the most used filter terms this is not doable.



I must say I am very surprised if this hasn't come up somewhere before - I'd have thought there'd be a specific documented way to do this.


What you could also do is have List reference field on your department that could contain parent department for one and child department for the other. This would allow you to build conditions like Parent department contains X or Child departments contains X. You could populate that field with a business rule or a calculated value (sometime calculated value can have issue with queries from my experience).


Thanks



I already have a reference field on department called parent which is a reference field to the departments table allowing a hierarchy of departments, the problem is then using that.   How do I query all users who are in Operations when no user has Operations as their department - their departments are all lower level departments because you can't have someone in just operations, they have to be in a department within operations.



When someone non-technical writes a report they need to be able to filter for all users in a department (such as operations) and actually get all the users for all of the sub-departments (Service Desk, Field Engineering and Systems) however far that goes (the department's children, all of it's children, and it's children etc.)



I will need the same solution for user criteria so I can only show items on the web portal to people in departments (e.g. operations) and the someone in Systems would see the item.



I hope this is a bit clearer.