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/12] 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/12] 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/12] 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/12] 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/12] 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/12] 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 ebc852cd075f56692e497161a6d579715b5caf59 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Sun, 14 Dec 2025 20:20:40 +0530 Subject: [PATCH 07/12] Add getJson function to fetch table fields --- Specialized Areas/Fix scripts/script.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Specialized Areas/Fix scripts/script.js diff --git a/Specialized Areas/Fix scripts/script.js b/Specialized Areas/Fix scripts/script.js new file mode 100644 index 0000000000..5b5b6d20db --- /dev/null +++ b/Specialized Areas/Fix scripts/script.js @@ -0,0 +1,12 @@ +getJson('incident', 'rfc,caller_id'); // pass table name and field names comma separated. +function getJson(tableName, fields) { + var jsonObj = {}; + var eQry = gs.nil(fields) ? 'name=' + tableName : 'name=' + tableName + '^elementIN' + fields; // generate JSON of enitre table if no fields are specified. + var dict = new GlideRecord('sys_dictionary'); + dict.addEncodedQuery(eQry); + dict.query(); + while (dict.next()) { + jsonObj[dict.element] = ''; + } + gs.print(JSON.stringify(jsonObj)); +} From 883c547794d61255232c98ac6fc211299916d640 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Sun, 14 Dec 2025 20:21:15 +0530 Subject: [PATCH 08/12] Delete Specialized Areas/Fix scripts/script.js --- Specialized Areas/Fix scripts/script.js | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 Specialized Areas/Fix scripts/script.js diff --git a/Specialized Areas/Fix scripts/script.js b/Specialized Areas/Fix scripts/script.js deleted file mode 100644 index 5b5b6d20db..0000000000 --- a/Specialized Areas/Fix scripts/script.js +++ /dev/null @@ -1,12 +0,0 @@ -getJson('incident', 'rfc,caller_id'); // pass table name and field names comma separated. -function getJson(tableName, fields) { - var jsonObj = {}; - var eQry = gs.nil(fields) ? 'name=' + tableName : 'name=' + tableName + '^elementIN' + fields; // generate JSON of enitre table if no fields are specified. - var dict = new GlideRecord('sys_dictionary'); - dict.addEncodedQuery(eQry); - dict.query(); - while (dict.next()) { - jsonObj[dict.element] = ''; - } - gs.print(JSON.stringify(jsonObj)); -} From 2dacbe40c33b75b94fa9088f444fef1754e69d06 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Sun, 14 Dec 2025 20:22:29 +0530 Subject: [PATCH 09/12] Add getJson function for JSON table retrieval Implement getJson function to retrieve table fields as JSON. --- .../Fix scripts/Create Table JSON/script.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Specialized Areas/Fix scripts/Create Table JSON/script.js diff --git a/Specialized Areas/Fix scripts/Create Table JSON/script.js b/Specialized Areas/Fix scripts/Create Table JSON/script.js new file mode 100644 index 0000000000..5b5b6d20db --- /dev/null +++ b/Specialized Areas/Fix scripts/Create Table JSON/script.js @@ -0,0 +1,12 @@ +getJson('incident', 'rfc,caller_id'); // pass table name and field names comma separated. +function getJson(tableName, fields) { + var jsonObj = {}; + var eQry = gs.nil(fields) ? 'name=' + tableName : 'name=' + tableName + '^elementIN' + fields; // generate JSON of enitre table if no fields are specified. + var dict = new GlideRecord('sys_dictionary'); + dict.addEncodedQuery(eQry); + dict.query(); + while (dict.next()) { + jsonObj[dict.element] = ''; + } + gs.print(JSON.stringify(jsonObj)); +} From 9f18b15f6832c6d354a1ce17f74fd2b162d023df Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Sun, 14 Dec 2025 20:25:34 +0530 Subject: [PATCH 10/12] Add README for Create Table JSON script Added documentation for the Fix script to create JSON from a table. --- Specialized Areas/Fix scripts/Create Table JSON/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Specialized Areas/Fix scripts/Create Table JSON/README.md diff --git a/Specialized Areas/Fix scripts/Create Table JSON/README.md b/Specialized Areas/Fix scripts/Create Table JSON/README.md new file mode 100644 index 0000000000..6bb9037051 --- /dev/null +++ b/Specialized Areas/Fix scripts/Create Table JSON/README.md @@ -0,0 +1,3 @@ +This Fix script will create JSON of all or specified fields of a table. +The developer need to pass the table andm and fieldnames to function. If no field name is specified, the JSON will contain all fields of table. +This will be helpful incase of inbound integrations where the third part application needs JSON format of table. From 85cd5f214718fee7893b14de684b9f514d4e0e9d Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Sun, 14 Dec 2025 20:27:28 +0530 Subject: [PATCH 11/12] Fix typo in README for JSON creation script Corrected a typo in the README regarding field names. --- Specialized Areas/Fix scripts/Create Table JSON/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Specialized Areas/Fix scripts/Create Table JSON/README.md b/Specialized Areas/Fix scripts/Create Table JSON/README.md index 6bb9037051..4a657b2418 100644 --- a/Specialized Areas/Fix scripts/Create Table JSON/README.md +++ b/Specialized Areas/Fix scripts/Create Table JSON/README.md @@ -1,3 +1,3 @@ This Fix script will create JSON of all or specified fields of a table. -The developer need to pass the table andm and fieldnames to function. If no field name is specified, the JSON will contain all fields of table. +The developer need to pass the table and and fieldnames to function. If no field name is specified, the JSON will contain all fields of table. This will be helpful incase of inbound integrations where the third part application needs JSON format of table. From 8be26c3c11c936f1b65f0844680bc4baba9b0afe Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Mon, 15 Dec 2025 14:13:22 +0530 Subject: [PATCH 12/12] Change gs.print to return JSON string --- Specialized Areas/Fix scripts/Create Table JSON/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Specialized Areas/Fix scripts/Create Table JSON/script.js b/Specialized Areas/Fix scripts/Create Table JSON/script.js index 5b5b6d20db..1ecd6e64e2 100644 --- a/Specialized Areas/Fix scripts/Create Table JSON/script.js +++ b/Specialized Areas/Fix scripts/Create Table JSON/script.js @@ -8,5 +8,5 @@ function getJson(tableName, fields) { while (dict.next()) { jsonObj[dict.element] = ''; } - gs.print(JSON.stringify(jsonObj)); + return JSON.stringify(jsonObj); }