Skip to content

Commit a2dcfe9

Browse files
authored
ScriptInclude.js
1 parent b236776 commit a2dcfe9

File tree

1 file changed

+21
-0
lines changed
  • Client-Side Components/Client Scripts/Auto-Add Watch List Based on Caller

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
var WatchListHelper = Class.create();
2+
WatchListHelper.prototype = Object.extendsObject(AbstractAjaxProcessor, {
3+
4+
getWatchListByCaller: function() {
5+
var callerId = this.getParameter('sysparm_caller');
6+
var watchListSysIds = [];
7+
var userGR = new GlideRecord('sys_user');
8+
if (userGR.get(callerId) && userGR.department) {
9+
// Fetch department managers
10+
var dept = new GlideRecord('cmn_department');
11+
if (dept.get(userGR.department)) {
12+
if (dept.manager)
13+
watchListSysIds.push(dept.manager.sys_id.toString());
14+
}
15+
}
16+
// Return as comma separated string
17+
return watchListSysIds.join(',');
18+
},
19+
20+
type: 'WatchListHelper'
21+
});

0 commit comments

Comments
 (0)