From 0a66b30ada9bd90098243443d8f70914d1c3ead2 Mon Sep 17 00:00:00 2001 From: sandeep-rajput-infobeans Date: Mon, 20 Oct 2025 01:22:12 +0530 Subject: [PATCH 1/3] Create Read.md This folder contains the script to fetch the complete manager hierarchy of person. --- .../Background Scripts/Get Manager Hierarchy/Read.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Server-Side Components/Background Scripts/Get Manager Hierarchy/Read.md diff --git a/Server-Side Components/Background Scripts/Get Manager Hierarchy/Read.md b/Server-Side Components/Background Scripts/Get Manager Hierarchy/Read.md new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/Server-Side Components/Background Scripts/Get Manager Hierarchy/Read.md @@ -0,0 +1 @@ + From 66a4d7b16b40eb2f437b84d37329bc37a1404bac Mon Sep 17 00:00:00 2001 From: sandeep-rajput-infobeans Date: Mon, 20 Oct 2025 01:25:42 +0530 Subject: [PATCH 2/3] Create getManagerHierarchy.js Function to get the complete manager hierarchy --- .../Get Manager Hierarchy/getManagerHierarchy.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Server-Side Components/Background Scripts/Get Manager Hierarchy/getManagerHierarchy.js diff --git a/Server-Side Components/Background Scripts/Get Manager Hierarchy/getManagerHierarchy.js b/Server-Side Components/Background Scripts/Get Manager Hierarchy/getManagerHierarchy.js new file mode 100644 index 0000000000..d44be11f88 --- /dev/null +++ b/Server-Side Components/Background Scripts/Get Manager Hierarchy/getManagerHierarchy.js @@ -0,0 +1,16 @@ +//Recursive function to get the complete manager hierarchy +//Param 1: managerArray an Array to hold manager hierarchy +//Param 2: next is representing next person in the manager hierarchy +function getManagerHierarchy(managerArray, next) { + var glideRecord = new GlideRecord('sys_user'); + if (glideRecord.get(next)) {//Check if there is a user record + managerArray.push(glideRecord.manager.name + '');//Add the user detail to the manager array + return getManagerHierarchy(managerArray, glideRecord.getValue('manager')); //Recursively call the same method to get the details of manager + + } else {//No more manager found return the array to callling function + return managerArray.toString().split(',').join(" >> ").substring(0, managerArray.toString().split(',').join(" >> ").length-4); + } +} + +var managerArray = []; +gs.info(getManagerHierarchy(managerArray, '22826bf03710200044e0bfc8bcbe5dec')); //Pass the sys_id of person here From 2926aef64ceb88ca8752383ba7de1adb2f5f7821 Mon Sep 17 00:00:00 2001 From: sandeep-rajput-infobeans Date: Mon, 20 Oct 2025 01:36:07 +0530 Subject: [PATCH 3/3] Update Read.md Updated Read.md file with examples. --- .../Background Scripts/Get Manager Hierarchy/Read.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Server-Side Components/Background Scripts/Get Manager Hierarchy/Read.md b/Server-Side Components/Background Scripts/Get Manager Hierarchy/Read.md index 8b13789179..f115092b45 100644 --- a/Server-Side Components/Background Scripts/Get Manager Hierarchy/Read.md +++ b/Server-Side Components/Background Scripts/Get Manager Hierarchy/Read.md @@ -1 +1,10 @@ +**Get the complete hierarchy of the managers for a given user.** +This script uses a recursive function to fetch the complete list of managers for any given user. Consider the following example. +Screenshot 2025-10-20 at 1 29 11 AM + +In this example user Abel Tutor reports to Abraham Lincoln, Abrham reports to Adela Cervantsz, Adela reports to Aileen Mottern and so on. + +In order to fetch this complete hierachy the getManagerHierachy script can be used. Here is the example of this script with output. +Screenshot 2025-10-20 at 1 34 36 AM +