diff --git a/Core ServiceNow APIs/GlideSystem/getCurrentScopeName/README.md b/Core ServiceNow APIs/GlideSystem/getCurrentScopeName/README.md new file mode 100644 index 0000000000..bd0437f370 --- /dev/null +++ b/Core ServiceNow APIs/GlideSystem/getCurrentScopeName/README.md @@ -0,0 +1,13 @@ +**getCurrentScopeName()** is a GlideSystem method to get the name of the current application scope. Following code can be used to get the name. + +gs.info(gs.getCurrentScopeName());//prints rhino.global if ran in Global scope + +Scope can be changed from the Application Scope Picker. + +Screenshot 2025-10-20 at 9 34 00 AM + +If ran in a private application scope the output will contain the name of the private application. + +Screenshot 2025-10-20 at 9 35 12 AM + + diff --git a/Core ServiceNow APIs/GlideSystem/getCurrentScopeName/getCurrentScopeName.js b/Core ServiceNow APIs/GlideSystem/getCurrentScopeName/getCurrentScopeName.js new file mode 100644 index 0000000000..aea36951f2 --- /dev/null +++ b/Core ServiceNow APIs/GlideSystem/getCurrentScopeName/getCurrentScopeName.js @@ -0,0 +1 @@ +gs.info(gs.getCurrentScopeName()); //prints the name of application scope. 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..f115092b45 --- /dev/null +++ b/Server-Side Components/Background Scripts/Get Manager Hierarchy/Read.md @@ -0,0 +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 + + 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