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/14] 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/14] 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/14] 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/14] 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/14] 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/14] 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 7d0cd6afd6520ac97e4a85aad8dd3c467ea20717 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Tue, 28 Oct 2025 22:56:43 +0530 Subject: [PATCH 07/14] Create script.js --- .../Cacel Struck Slack Conversations/script.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/script.js diff --git a/Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/script.js b/Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/script.js new file mode 100644 index 0000000000..f9c552a6d2 --- /dev/null +++ b/Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/script.js @@ -0,0 +1,12 @@ +/* +This script will mark the struck slack conversation as canceled. +Use Case: Sometimes due to n/w or connecton issue, users are not able to end the conversations using restart or end command from slack. +*/ +var struckConv = new GlideRecord('sys_cs_conversation'); // conversation table glide record +struckConv.addEncodedQuery('stateINopen,faulted,chatInProgress^device_type=slack'); // Query can ve enhanced based on user (consumer) or date range. +struckConv.query(); +while(struckConv.next()){ + struckConv.setValue('state','canceled'); // set the state to cancel for struck conversation. + struckConv.setWorkflow(false); + struckConv.update(); +} From b0dd356301ce857ce10de1cc12877feb13e80399 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Tue, 28 Oct 2025 22:58:20 +0530 Subject: [PATCH 08/14] Create README.md --- .../Fix scripts/Cacel Struck Slack Conversations/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/README.md diff --git a/Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/README.md b/Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/README.md new file mode 100644 index 0000000000..6ad195a487 --- /dev/null +++ b/Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/README.md @@ -0,0 +1,3 @@ +**Use Case** +Sometimes due to networkw or connecton issue, users are not able to end the conversations using restart or end command from slack. +This script will cancel the struck conversations, allwing the users to interaction with ServiceNow again through slack. From dc205d1697d00e791277bbb194d49488e98889a1 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Tue, 28 Oct 2025 22:58:57 +0530 Subject: [PATCH 09/14] Update README.md --- .../Fix scripts/Cacel Struck Slack Conversations/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/README.md b/Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/README.md index 6ad195a487..dca4a7d085 100644 --- a/Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/README.md +++ b/Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/README.md @@ -1,3 +1,3 @@ **Use Case** -Sometimes due to networkw or connecton issue, users are not able to end the conversations using restart or end command from slack. -This script will cancel the struck conversations, allwing the users to interaction with ServiceNow again through slack. +Sometimes due to network or connecton issue, users are not able to end the conversations using **restart** or **end** command from slack. +This script will cancel the struck conversations, allowing the users to interaction with ServiceNow again through slack. From 58ea522bbd8d52dcce0395fe6424522cbadea8eb Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Tue, 28 Oct 2025 22:59:41 +0530 Subject: [PATCH 10/14] Update script.js --- .../Fix scripts/Cacel Struck Slack Conversations/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/script.js b/Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/script.js index f9c552a6d2..4d3ccc81f3 100644 --- a/Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/script.js +++ b/Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/script.js @@ -3,7 +3,7 @@ This script will mark the struck slack conversation as canceled. Use Case: Sometimes due to n/w or connecton issue, users are not able to end the conversations using restart or end command from slack. */ var struckConv = new GlideRecord('sys_cs_conversation'); // conversation table glide record -struckConv.addEncodedQuery('stateINopen,faulted,chatInProgress^device_type=slack'); // Query can ve enhanced based on user (consumer) or date range. +struckConv.addEncodedQuery('stateINopen,faulted,chatInProgress^device_type=slack'); // Query can be enhanced based on user (consumer) or date range. struckConv.query(); while(struckConv.next()){ struckConv.setValue('state','canceled'); // set the state to cancel for struck conversation. From bf93048ff0fac1368c21d4e3414f5fb71761364e Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Wed, 29 Oct 2025 12:04:57 +0530 Subject: [PATCH 11/14] Update and rename README.md to README.md --- .../Fix scripts/Cacel Struck Slack Conversations/README.md | 3 --- .../Fix scripts/Cancel Struck Slack Conversations/README.md | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) delete mode 100644 Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/README.md create mode 100644 Specialized Areas/Fix scripts/Cancel Struck Slack Conversations/README.md diff --git a/Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/README.md b/Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/README.md deleted file mode 100644 index dca4a7d085..0000000000 --- a/Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/README.md +++ /dev/null @@ -1,3 +0,0 @@ -**Use Case** -Sometimes due to network or connecton issue, users are not able to end the conversations using **restart** or **end** command from slack. -This script will cancel the struck conversations, allowing the users to interaction with ServiceNow again through slack. diff --git a/Specialized Areas/Fix scripts/Cancel Struck Slack Conversations/README.md b/Specialized Areas/Fix scripts/Cancel Struck Slack Conversations/README.md new file mode 100644 index 0000000000..57d6d8515d --- /dev/null +++ b/Specialized Areas/Fix scripts/Cancel Struck Slack Conversations/README.md @@ -0,0 +1,4 @@ +**Use Case** +1. Sometimes due to network or connecton issue, users are not able to end the conversations using **restart** or **end** command from slack. +2. This script will cancel the struck slack conversations, allowing the users to interaction with ServiceNow again through slack. +3. The encoded Qyery device type specify the source of conversation. From 82a5852e6264f645b93c953443bc4a840caa9cab Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Wed, 29 Oct 2025 12:05:13 +0530 Subject: [PATCH 12/14] Update README.md --- .../Fix scripts/Cancel Struck Slack Conversations/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Specialized Areas/Fix scripts/Cancel Struck Slack Conversations/README.md b/Specialized Areas/Fix scripts/Cancel Struck Slack Conversations/README.md index 57d6d8515d..c3959e454b 100644 --- a/Specialized Areas/Fix scripts/Cancel Struck Slack Conversations/README.md +++ b/Specialized Areas/Fix scripts/Cancel Struck Slack Conversations/README.md @@ -1,4 +1,4 @@ **Use Case** 1. Sometimes due to network or connecton issue, users are not able to end the conversations using **restart** or **end** command from slack. 2. This script will cancel the struck slack conversations, allowing the users to interaction with ServiceNow again through slack. -3. The encoded Qyery device type specify the source of conversation. +3. The encoded Query device type specify the source of conversation. From c46408331261dd68e4e3e0368a09840e0d8ad11b Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Wed, 29 Oct 2025 12:07:45 +0530 Subject: [PATCH 13/14] Create script.js --- .../Cancel Struck Slack Conversations/script.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Specialized Areas/Fix scripts/Cancel Struck Slack Conversations/script.js diff --git a/Specialized Areas/Fix scripts/Cancel Struck Slack Conversations/script.js b/Specialized Areas/Fix scripts/Cancel Struck Slack Conversations/script.js new file mode 100644 index 0000000000..b3d4dc95f2 --- /dev/null +++ b/Specialized Areas/Fix scripts/Cancel Struck Slack Conversations/script.js @@ -0,0 +1,13 @@ +/* +This script will mark the struck slack conversation as canceled. +Use Case: Sometimes due to n/w or connecton issue, users are not able to end the conversations using restart or end command from slack. +Device Type in Encoded Query specify the source of conversation, slack in this case. +*/ +var struckConv = new GlideRecord('sys_cs_conversation'); // conversation table glide record +struckConv.addEncodedQuery('stateINopen,faulted,chatInProgress^device_type=slack'); // Query can be enhanced based on user (consumer) or date range. +struckConv.query(); +while(struckConv.next()){ + struckConv.setValue('state','canceled'); // set the state to cancel for struck conversation. + struckConv.setWorkflow(false); + struckConv.update(); +} From 180255d43239bb644d8f7cda0e61d628d8c2f5e5 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Wed, 29 Oct 2025 12:08:55 +0530 Subject: [PATCH 14/14] Delete Specialized Areas/Fix scripts/Cacel Struck Slack Conversations directory --- .../Cacel Struck Slack Conversations/script.js | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/script.js diff --git a/Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/script.js b/Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/script.js deleted file mode 100644 index 4d3ccc81f3..0000000000 --- a/Specialized Areas/Fix scripts/Cacel Struck Slack Conversations/script.js +++ /dev/null @@ -1,12 +0,0 @@ -/* -This script will mark the struck slack conversation as canceled. -Use Case: Sometimes due to n/w or connecton issue, users are not able to end the conversations using restart or end command from slack. -*/ -var struckConv = new GlideRecord('sys_cs_conversation'); // conversation table glide record -struckConv.addEncodedQuery('stateINopen,faulted,chatInProgress^device_type=slack'); // Query can be enhanced based on user (consumer) or date range. -struckConv.query(); -while(struckConv.next()){ - struckConv.setValue('state','canceled'); // set the state to cancel for struck conversation. - struckConv.setWorkflow(false); - struckConv.update(); -}