From b23677658d2c46fae6132aadc3ecfce06cec08be Mon Sep 17 00:00:00 2001 From: Indra-kolge <123245160+Indra-kolge@users.noreply.github.com> Date: Sat, 18 Oct 2025 00:38:07 +0530 Subject: [PATCH 1/3] ClientScript.js --- .../ClientScript.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Auto-Add Watch List Based on Caller/ClientScript.js diff --git a/Client-Side Components/Client Scripts/Auto-Add Watch List Based on Caller/ClientScript.js b/Client-Side Components/Client Scripts/Auto-Add Watch List Based on Caller/ClientScript.js new file mode 100644 index 0000000000..43aba52642 --- /dev/null +++ b/Client-Side Components/Client Scripts/Auto-Add Watch List Based on Caller/ClientScript.js @@ -0,0 +1,16 @@ +function onChange(control, oldValue, newValue, isLoading) { +if (isLoading || !newValue) return; + +// GlideAjax call to fetch department leads +var ga = new GlideAjax('WatchListHelper'); +ga.addParam('sysparm_name', 'getWatchListByCaller'); +ga.addParam('sysparm_caller', newValue); +ga.getXMLAnswer(function(answer) { +if (answer) { +// answer is comma separated list of sys_ids +var currentWatchList = g_form.getValue('watch_list'); +var combined = currentWatchList ? currentWatchList + ',' + answer : answer; +g_form.setValue('watch_list', combined); +} +}); +} From a2dcfe94c77a0e895268ed06c74726b38d677798 Mon Sep 17 00:00:00 2001 From: Indra-kolge <123245160+Indra-kolge@users.noreply.github.com> Date: Sat, 18 Oct 2025 00:43:58 +0530 Subject: [PATCH 2/3] ScriptInclude.js --- .../ScriptInclude.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Auto-Add Watch List Based on Caller/ScriptInclude.js diff --git a/Client-Side Components/Client Scripts/Auto-Add Watch List Based on Caller/ScriptInclude.js b/Client-Side Components/Client Scripts/Auto-Add Watch List Based on Caller/ScriptInclude.js new file mode 100644 index 0000000000..01b1504358 --- /dev/null +++ b/Client-Side Components/Client Scripts/Auto-Add Watch List Based on Caller/ScriptInclude.js @@ -0,0 +1,21 @@ +var WatchListHelper = Class.create(); +WatchListHelper.prototype = Object.extendsObject(AbstractAjaxProcessor, { + +getWatchListByCaller: function() { +var callerId = this.getParameter('sysparm_caller'); +var watchListSysIds = []; +var userGR = new GlideRecord('sys_user'); +if (userGR.get(callerId) && userGR.department) { +// Fetch department managers +var dept = new GlideRecord('cmn_department'); +if (dept.get(userGR.department)) { +if (dept.manager) + watchListSysIds.push(dept.manager.sys_id.toString()); +} +} +// Return as comma separated string +return watchListSysIds.join(','); +}, + +type: 'WatchListHelper' +}); From 4fe39b2e41b62f680c4d81a024594f4634ef8c35 Mon Sep 17 00:00:00 2001 From: Indra-kolge <123245160+Indra-kolge@users.noreply.github.com> Date: Sat, 18 Oct 2025 00:47:41 +0530 Subject: [PATCH 3/3] README.md --- .../Auto-Add Watch List Based on Caller/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Auto-Add Watch List Based on Caller/README.md diff --git a/Client-Side Components/Client Scripts/Auto-Add Watch List Based on Caller/README.md b/Client-Side Components/Client Scripts/Auto-Add Watch List Based on Caller/README.md new file mode 100644 index 0000000000..a7416e7a7c --- /dev/null +++ b/Client-Side Components/Client Scripts/Auto-Add Watch List Based on Caller/README.md @@ -0,0 +1,15 @@ + +Auto-Add Watch List Based on Caller Department + +//Use Case : + +Automatically adds relevant users to the Watch List field when a Caller is selected on Incident. +Keep department leads or stakeholders automatically informed. + +//Logic: + +Client Script runs onChange of the Caller field. +Calls a Client callable Script Include ('WatchListHelper) via GlideAjax. +Script Include fetches Department manager +Adds their sys_id to the Watch List field. +Prevents duplicates by appending to existing watch list values.