|
| 1 | +# Summary # |
1 | 2 | This looping script traverses the User table from a certain point to get either one level of employees or all employees in the hierarchy underneath the logged-on user. There are two functions:
|
2 |
| -1. **getMyDirectReports**: gets only users directly reporting to the logged on user |
3 |
| -1. **getMyReports**: gets all users reporting to the logged on user |
| 3 | +1. **One of My Direct Reports**: gets only users directly reporting to the logged on user |
| 4 | +1. **One of My Reports**: gets all users reporting to the logged on user |
4 | 5 |
|
5 |
| -This solution has three components: one Global Business rule and two Dynamic Filters. |
| 6 | +> [!WARNING] |
| 7 | +> There is some recursion protection, but the use of this script could have performance impacts for very large organizations. Use at your discretion. |
| 8 | +
|
| 9 | +**How to Use** |
6 | 10 | * Admins can use the script as a Reference Qualifier
|
7 |
| -* End Users can select the predefined filter in lists and reports (like with "One of My Assignments"). |
| 11 | +* Users (with platform access) can select the predefined filter in lists and reports (like with "One of My Assignments"). |
8 | 12 |
|
9 |
| -There is some recursion protection; the script checks to see if it has already collected the User before it tries to get their direct reports. |
| 13 | +# Solution # |
| 14 | +This solution has three main components: |
| 15 | +* 1 Client Callable Script Include |
| 16 | +* 2 Dynamic Filters |
10 | 17 |
|
11 |
| -**IMPORTANT: The use of this script could have performance impacts for very large organizations. Use at your discretion.** |
| 18 | +> [!NOTE] |
| 19 | +> You will also need to create an ACL for your client callable script include. Think through other security rules before using this filter broadly for users without roles. OOTB Users without roles are often restricted to seeing only their items, for example, a User without itil or snc_incident_read typically cannot see other user's Incidents unless they are the Opened by or are on the Watch list. Make sure you test as the users you hope to publish this item to. |
12 | 20 |
|
13 |
| -**Business Rule** |
| 21 | +## Script Include (sys_script_include) ## |
14 | 22 |
|
15 | 23 | | Field | Value |
|
16 | 24 | |---|---|
|
17 |
| -| Name | getMyDirectReports | |
18 |
| -| Table | Global [global] | |
19 |
| -| Advanced | true | |
20 |
| -| Script | <em>see [getMyDirectReports.js](getMyDirectReports.js) in this folder</em> | |
| 25 | +| Name | getMyReportsUtil | |
| 26 | +| Client Callable | true | |
| 27 | +| Script | <em>see [getMyReportsUtil.js](getMyReportsUtil.js)</em> | |
| 28 | + |
| 29 | +## Dynamic Filter Option (sys_filter_option_dynamic) ## |
21 | 30 |
|
22 |
| -**Dynamic Filter Option (sys_filter_option_dynamic)** |
| 31 | +### One of My Direct Reports ### |
23 | 32 |
|
24 | 33 | | Field | Value |
|
25 | 34 | |---|---|
|
26 | 35 | | Label | One of My Direct Reports |
|
27 |
| -| Script | getMyDirectReports() | |
| 36 | +| Script | new global.getMyReportsUtil().getMyDirectReports() | |
28 | 37 | | Field type | Reference |
|
29 | 38 | | Reference Table | User [sys_user] |
|
30 | 39 | | Order | 500 |
|
31 |
| -| Reference script | Business Rule: getMyDirectReports | |
| 40 | +| Roles | Choose the same role(s) you added to the Script Include ACL | |
| 41 | +| Reference script | Script Include: getMyReportsUtil | |
32 | 42 | | Available for filter | true |
|
33 | 43 | | Available for ref qual | true |
|
34 | 44 |
|
| 45 | +**Example Incident list filtered by Caller is One of My Direct Reports** |
| 46 | + |
| 47 | + |
| 48 | +### One of My Reports ### |
| 49 | + |
35 | 50 | | Field | Value |
|
36 | 51 | |---|---|
|
37 | 52 | | Label | One of My Reports |
|
38 |
| -| Script | getMyReports() | |
| 53 | +| Script | new global.getMyReportsUtil().getMyReports() | |
39 | 54 | | Field type | Reference |
|
40 | 55 | | Reference Table | User [sys_user] |
|
41 | 56 | | Order | 600 |
|
42 |
| -| Reference script | Business Rule: getMyDirectReports | |
| 57 | +| Roles | Choose the same role(s) you added to the Script Include ACL | |
| 58 | +| Reference script | Script Include: getMyReportsUtil | |
43 | 59 | | Available for filter | true |
|
44 | 60 | | Available for ref qual | true |
|
| 61 | + |
| 62 | +**Example Incident list filtered by Caller is One of My Reports** |
| 63 | + |
| 64 | + |
| 65 | + ### Example Manager Data for the screenshots above ### |
| 66 | + |
| 67 | + |
0 commit comments