Loop through user's manager in hierarchy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2023 08:47 AM
Hi All,
I need some help to design the solution.
In my use case, I have 5 managers in user table, so I know the sys_ids and users name. I have created a sys property to store all these sys_ids.
Now, I want to loop through the manager field until 1 of the 5 managers is found at any level.
Once match found, return the manager (N) sys id and sys_id of the manager at a level below (N-1).
For example, caller 1 has 7th levels till the manager is found but for caller 2 the same manager could be at 9th level.
Caller 1 > M1 > M2 >M3 >.... M(N-1) > M(N)
Caller 2 > M1 > M2 >M3 > M4 > M5 >.... M(N-1) > M(N)
I have tried few solutions from community but didn't get correct result.
Please help with the script or logic.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 12:06 AM
Any luck in finding the solution for this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 06:46 AM
Hi Chenab,
Here is the example script.