Skip to content

Commit b236776

Browse files
authored
ClientScript.js
1 parent 599f55e commit b236776

File tree

1 file changed

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

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function onChange(control, oldValue, newValue, isLoading) {
2+
if (isLoading || !newValue) return;
3+
4+
// GlideAjax call to fetch department leads
5+
var ga = new GlideAjax('WatchListHelper');
6+
ga.addParam('sysparm_name', 'getWatchListByCaller');
7+
ga.addParam('sysparm_caller', newValue);
8+
ga.getXMLAnswer(function(answer) {
9+
if (answer) {
10+
// answer is comma separated list of sys_ids
11+
var currentWatchList = g_form.getValue('watch_list');
12+
var combined = currentWatchList ? currentWatchList + ',' + answer : answer;
13+
g_form.setValue('watch_list', combined);
14+
}
15+
});
16+
}

0 commit comments

Comments
 (0)