From 31d7cdd0f9dd2a5526aca747329f78877aab1237 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Wed, 22 Oct 2025 20:02:59 +0530 Subject: [PATCH 01/11] Add script to display user mentions in Service Portal This script retrieves and displays the top 5 records where the logged-in user is mentioned, providing links to those records. --- .../My Mentioned Items/server.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Modern Development/Service Portal Widgets/My Mentioned Items/server.js diff --git a/Modern Development/Service Portal Widgets/My Mentioned Items/server.js b/Modern Development/Service Portal Widgets/My Mentioned Items/server.js new file mode 100644 index 0000000000..c7acf63dc1 --- /dev/null +++ b/Modern Development/Service Portal Widgets/My Mentioned Items/server.js @@ -0,0 +1,21 @@ +(function() { + /* + This code will get display the records wher user is mentioned. + This will also provide the link to record. + Only top 5 mentions will be displayed. + */ + data.mentionArr = []; // array to store mentions. + var mentionRec = new GlideRecord('live_notification'); + mentionRec.addEncodedQuery('user=' + gs.getUserID()); // get only logged-in user's records + mentionRec.orderBy('sys_created_on'); // get by created date. + mentionRec.setLimit(5); + mentionRec.query(); + while (mentionRec.next()) { + tempval = {}; // temp object. + tempval.record = mentionRec.getValue('title'); + tempval.user = mentionRec.user.name.toString(); + tempval.user_from = mentionRec.user_from.name.toString(); + tempval.url = '/' + $sp.getValue('url_suffix') + '?id=ticket&sys_id=' + mentionRec.getValue('document') + '&table=' + mentionRec.getValue('table'); + data.mentionArr.push(tempval); + } +})(); From c06f8741cbef5176d513c8080f60be3d67354a6f Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Wed, 22 Oct 2025 20:18:48 +0530 Subject: [PATCH 02/11] Delete Modern Development/Service Portal Widgets/My Mentioned Items directory --- .../My Mentioned Items/server.js | 21 ------------------- 1 file changed, 21 deletions(-) delete mode 100644 Modern Development/Service Portal Widgets/My Mentioned Items/server.js diff --git a/Modern Development/Service Portal Widgets/My Mentioned Items/server.js b/Modern Development/Service Portal Widgets/My Mentioned Items/server.js deleted file mode 100644 index c7acf63dc1..0000000000 --- a/Modern Development/Service Portal Widgets/My Mentioned Items/server.js +++ /dev/null @@ -1,21 +0,0 @@ -(function() { - /* - This code will get display the records wher user is mentioned. - This will also provide the link to record. - Only top 5 mentions will be displayed. - */ - data.mentionArr = []; // array to store mentions. - var mentionRec = new GlideRecord('live_notification'); - mentionRec.addEncodedQuery('user=' + gs.getUserID()); // get only logged-in user's records - mentionRec.orderBy('sys_created_on'); // get by created date. - mentionRec.setLimit(5); - mentionRec.query(); - while (mentionRec.next()) { - tempval = {}; // temp object. - tempval.record = mentionRec.getValue('title'); - tempval.user = mentionRec.user.name.toString(); - tempval.user_from = mentionRec.user_from.name.toString(); - tempval.url = '/' + $sp.getValue('url_suffix') + '?id=ticket&sys_id=' + mentionRec.getValue('document') + '&table=' + mentionRec.getValue('table'); - data.mentionArr.push(tempval); - } -})(); From 1e5fce571bccf37ba3b70002c29737f99afcff02 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Wed, 22 Oct 2025 20:22:42 +0530 Subject: [PATCH 03/11] Create script.js --- .../My Mentioned Items/script.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Modern Development/Service Portal Widgets/My Mentioned Items/script.js diff --git a/Modern Development/Service Portal Widgets/My Mentioned Items/script.js b/Modern Development/Service Portal Widgets/My Mentioned Items/script.js new file mode 100644 index 0000000000..c7acf63dc1 --- /dev/null +++ b/Modern Development/Service Portal Widgets/My Mentioned Items/script.js @@ -0,0 +1,21 @@ +(function() { + /* + This code will get display the records wher user is mentioned. + This will also provide the link to record. + Only top 5 mentions will be displayed. + */ + data.mentionArr = []; // array to store mentions. + var mentionRec = new GlideRecord('live_notification'); + mentionRec.addEncodedQuery('user=' + gs.getUserID()); // get only logged-in user's records + mentionRec.orderBy('sys_created_on'); // get by created date. + mentionRec.setLimit(5); + mentionRec.query(); + while (mentionRec.next()) { + tempval = {}; // temp object. + tempval.record = mentionRec.getValue('title'); + tempval.user = mentionRec.user.name.toString(); + tempval.user_from = mentionRec.user_from.name.toString(); + tempval.url = '/' + $sp.getValue('url_suffix') + '?id=ticket&sys_id=' + mentionRec.getValue('document') + '&table=' + mentionRec.getValue('table'); + data.mentionArr.push(tempval); + } +})(); From f368a8d2e60e996cf904d69ac8dabb6cbae9c622 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Wed, 22 Oct 2025 20:22:52 +0530 Subject: [PATCH 04/11] Delete Modern Development/Service Portal Widgets/My Mentioned Items directory --- .../My Mentioned Items/script.js | 21 ------------------- 1 file changed, 21 deletions(-) delete mode 100644 Modern Development/Service Portal Widgets/My Mentioned Items/script.js diff --git a/Modern Development/Service Portal Widgets/My Mentioned Items/script.js b/Modern Development/Service Portal Widgets/My Mentioned Items/script.js deleted file mode 100644 index c7acf63dc1..0000000000 --- a/Modern Development/Service Portal Widgets/My Mentioned Items/script.js +++ /dev/null @@ -1,21 +0,0 @@ -(function() { - /* - This code will get display the records wher user is mentioned. - This will also provide the link to record. - Only top 5 mentions will be displayed. - */ - data.mentionArr = []; // array to store mentions. - var mentionRec = new GlideRecord('live_notification'); - mentionRec.addEncodedQuery('user=' + gs.getUserID()); // get only logged-in user's records - mentionRec.orderBy('sys_created_on'); // get by created date. - mentionRec.setLimit(5); - mentionRec.query(); - while (mentionRec.next()) { - tempval = {}; // temp object. - tempval.record = mentionRec.getValue('title'); - tempval.user = mentionRec.user.name.toString(); - tempval.user_from = mentionRec.user_from.name.toString(); - tempval.url = '/' + $sp.getValue('url_suffix') + '?id=ticket&sys_id=' + mentionRec.getValue('document') + '&table=' + mentionRec.getValue('table'); - data.mentionArr.push(tempval); - } -})(); From df002e468c73339b41a6a708fb9e821a47f61dd6 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Thu, 23 Oct 2025 23:22:16 +0530 Subject: [PATCH 05/11] Create script.js --- .../Retire Rating 1 Articles/script.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Server-Side Components/Scheduled Jobs/Retire Rating 1 Articles/script.js diff --git a/Server-Side Components/Scheduled Jobs/Retire Rating 1 Articles/script.js b/Server-Side Components/Scheduled Jobs/Retire Rating 1 Articles/script.js new file mode 100644 index 0000000000..916255ec35 --- /dev/null +++ b/Server-Side Components/Scheduled Jobs/Retire Rating 1 Articles/script.js @@ -0,0 +1,21 @@ +/* +This schedule job will run daily EOD PST time. +This Job will look for articles which have been rated 1 three times and will retire those articles. + +*/ +var kbFeed = new GlideAggregate('kb_feedback'); +kbFeed.addEncodedQuery('rating=1'); // get articles with rating 1. +kbFeed.addAggregate('COUNT', 'article'); +kbFeed.groupBy('user'); +kbFeed.query(); +while (kbFeed.next()) { + + if (kbFeed.getAggregate('COUNT', 'article') >= 3) { + var updateArt = new GlideRecord('kb_knowledge'); + updateArt.get(kbFeed.article.sys_id); + if (updateArt.workflow_state == 'published') { + updateArt.workflow_state = 'retired'; + updateArt.update(); + } + } +} From 31be0ba0034e507585f31663e8e81b905ea66577 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Thu, 23 Oct 2025 23:22:30 +0530 Subject: [PATCH 06/11] Delete Server-Side Components/Scheduled Jobs/Retire Rating 1 Articles directory --- .../Retire Rating 1 Articles/script.js | 21 ------------------- 1 file changed, 21 deletions(-) delete mode 100644 Server-Side Components/Scheduled Jobs/Retire Rating 1 Articles/script.js diff --git a/Server-Side Components/Scheduled Jobs/Retire Rating 1 Articles/script.js b/Server-Side Components/Scheduled Jobs/Retire Rating 1 Articles/script.js deleted file mode 100644 index 916255ec35..0000000000 --- a/Server-Side Components/Scheduled Jobs/Retire Rating 1 Articles/script.js +++ /dev/null @@ -1,21 +0,0 @@ -/* -This schedule job will run daily EOD PST time. -This Job will look for articles which have been rated 1 three times and will retire those articles. - -*/ -var kbFeed = new GlideAggregate('kb_feedback'); -kbFeed.addEncodedQuery('rating=1'); // get articles with rating 1. -kbFeed.addAggregate('COUNT', 'article'); -kbFeed.groupBy('user'); -kbFeed.query(); -while (kbFeed.next()) { - - if (kbFeed.getAggregate('COUNT', 'article') >= 3) { - var updateArt = new GlideRecord('kb_knowledge'); - updateArt.get(kbFeed.article.sys_id); - if (updateArt.workflow_state == 'published') { - updateArt.workflow_state = 'retired'; - updateArt.update(); - } - } -} From 028626640c5bf4a11ceeece79bcc24cb3c6ea0bf Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Fri, 31 Oct 2025 19:28:15 +0530 Subject: [PATCH 07/11] Create script.js --- .../Restrict Fields on Template/script.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Restrict Fields on Template/script.js diff --git a/Client-Side Components/Client Scripts/Restrict Fields on Template/script.js b/Client-Side Components/Client Scripts/Restrict Fields on Template/script.js new file mode 100644 index 0000000000..d2fe3577fc --- /dev/null +++ b/Client-Side Components/Client Scripts/Restrict Fields on Template/script.js @@ -0,0 +1,20 @@ +/* +Type: OnChnage +Table: sys_template +Field: Template +*/ +function onChange(control, oldValue, newValue, isLoading, isTemplate) { + if (isLoading || newValue === '') { + return; + } + if (g_form.getValue('table') == 'incident') { // table on which sys_template is being created. + var fields = ['active', 'comments']; // array of fields to be restricted. + for (var i = 0; i < fields.length; i++) { + if (newValue.indexOf(fields[i]) > -1) { + alert("You Cannot Add " + fields[i]); // alert if user selects the restricted field. + var qry = newValue.split(fields[i]); + g_form.setValue('template', qry[0] + 'EQ'); // set the template value to previous values (oldValue does not work in this case). + } + } + } +} From b05761d28d7267c058eeac76c8816a99088b4f2d Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Fri, 31 Oct 2025 19:28:32 +0530 Subject: [PATCH 08/11] Update script.js --- .../Client Scripts/Restrict Fields on Template/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client-Side Components/Client Scripts/Restrict Fields on Template/script.js b/Client-Side Components/Client Scripts/Restrict Fields on Template/script.js index d2fe3577fc..326fa0ab01 100644 --- a/Client-Side Components/Client Scripts/Restrict Fields on Template/script.js +++ b/Client-Side Components/Client Scripts/Restrict Fields on Template/script.js @@ -1,5 +1,5 @@ /* -Type: OnChnage +Type: onChnage Table: sys_template Field: Template */ From 35f3c0b139b2a6ff97d0c6eff424ca170536b7b0 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Fri, 31 Oct 2025 19:34:12 +0530 Subject: [PATCH 09/11] Create README.md --- .../Restrict Fields on Template/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Restrict Fields on Template/README.md diff --git a/Client-Side Components/Client Scripts/Restrict Fields on Template/README.md b/Client-Side Components/Client Scripts/Restrict Fields on Template/README.md new file mode 100644 index 0000000000..a4fd75de5a --- /dev/null +++ b/Client-Side Components/Client Scripts/Restrict Fields on Template/README.md @@ -0,0 +1,10 @@ +**Details** +This is a on change client script on sys_template table. This script will restrict users to select defined fields while template creation. +Type: OnChange +Field: Template +Table: sys_template + +**Use Case** +There is an OOB functionality to restrict fields using "**save as template**" ACL, but it has below limitations: +1. If the requirement is to restrcit more number of fields (example: 20), 20 ACLs will have to be created. +2. The ACls will have instance wide effect, this script will just restrict on client side. From 42a9e16af65625c4dbfccb4ca98458c77c1b03b4 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Fri, 31 Oct 2025 19:34:38 +0530 Subject: [PATCH 10/11] Update README.md --- .../Client Scripts/Restrict Fields on Template/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Client-Side Components/Client Scripts/Restrict Fields on Template/README.md b/Client-Side Components/Client Scripts/Restrict Fields on Template/README.md index a4fd75de5a..6482017798 100644 --- a/Client-Side Components/Client Scripts/Restrict Fields on Template/README.md +++ b/Client-Side Components/Client Scripts/Restrict Fields on Template/README.md @@ -1,10 +1,12 @@ **Details** + This is a on change client script on sys_template table. This script will restrict users to select defined fields while template creation. Type: OnChange Field: Template Table: sys_template **Use Case** + There is an OOB functionality to restrict fields using "**save as template**" ACL, but it has below limitations: 1. If the requirement is to restrcit more number of fields (example: 20), 20 ACLs will have to be created. 2. The ACls will have instance wide effect, this script will just restrict on client side. From 14b8d00b75ea98ba74bfde00bb23c45c44f375f3 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Fri, 31 Oct 2025 19:35:10 +0530 Subject: [PATCH 11/11] Update script.js --- .../Client Scripts/Restrict Fields on Template/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client-Side Components/Client Scripts/Restrict Fields on Template/script.js b/Client-Side Components/Client Scripts/Restrict Fields on Template/script.js index 326fa0ab01..625f432899 100644 --- a/Client-Side Components/Client Scripts/Restrict Fields on Template/script.js +++ b/Client-Side Components/Client Scripts/Restrict Fields on Template/script.js @@ -8,7 +8,7 @@ function onChange(control, oldValue, newValue, isLoading, isTemplate) { return; } if (g_form.getValue('table') == 'incident') { // table on which sys_template is being created. - var fields = ['active', 'comments']; // array of fields to be restricted. + var fields = ['active', 'comments']; // array of fields to be restricted while template creation. for (var i = 0; i < fields.length; i++) { if (newValue.indexOf(fields[i]) > -1) { alert("You Cannot Add " + fields[i]); // alert if user selects the restricted field.