From afd4406bdae59b79d510284b29f5205ef4c7a299 Mon Sep 17 00:00:00 2001 From: SIVAMURUGANANDAM J <67639018+sivamuruganandam-coder@users.noreply.github.com> Date: Sun, 5 Oct 2025 09:47:04 +0530 Subject: [PATCH 01/21] Create Code.js --- .../code.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Server-Side Components/Business Rules/Add or remove a tag from the ticket whenever the comments are updated /code.js diff --git a/Server-Side Components/Business Rules/Add or remove a tag from the ticket whenever the comments are updated /code.js b/Server-Side Components/Business Rules/Add or remove a tag from the ticket whenever the comments are updated /code.js new file mode 100644 index 0000000000..8541d8ed8c --- /dev/null +++ b/Server-Side Components/Business Rules/Add or remove a tag from the ticket whenever the comments are updated /code.js @@ -0,0 +1,26 @@ +//Business Rule: After update on the incident table +//Condition: Additional comments changes +//Create on global Tag record ex: Comments added + +(function executeRule(current, previous /*null when async*/ ) { + + var caller = current.caller_id.user_name; +// Add tag to the incident record if the comments is updated by the caller + if (current.sys_updated_by == caller) { + var add_tag_entry = new GlideRecord('label_entry'); + add_tag_entry.initialize(); + add_tag_entry.label = ''; + add_tag_entry.table = 'incident'; + add_tag_entry.table_key = current.sys_id; + add_tag_entry.insert(); + } else { +// Remove tag from the incident record if the agent responds back to the caller + var remove_tag_entry = new GlideRecord('label_entry'); + remove_tag_entry.addEncodedQuery("label=^table_key=" + current.sys_id); + remove_tag_entry.query(); + if (remove_tag_entry.next()) { + remove_tag_entry.deleteRecord(); + } + } + +})(current, previous); From 99672a834fdc7c73c1a828df4e39c885e98413f7 Mon Sep 17 00:00:00 2001 From: SIVAMURUGANANDAM J <67639018+sivamuruganandam-coder@users.noreply.github.com> Date: Sun, 5 Oct 2025 09:51:01 +0530 Subject: [PATCH 02/21] Create README.md --- .../README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Server-Side Components/Business Rules/Add or remove a tag from the ticket whenever the comments are updated /README.md diff --git a/Server-Side Components/Business Rules/Add or remove a tag from the ticket whenever the comments are updated /README.md b/Server-Side Components/Business Rules/Add or remove a tag from the ticket whenever the comments are updated /README.md new file mode 100644 index 0000000000..e027157668 --- /dev/null +++ b/Server-Side Components/Business Rules/Add or remove a tag from the ticket whenever the comments are updated /README.md @@ -0,0 +1,2 @@ +The purpose of this code is to conditionally apply a specific label (label_entry) to an Incident when the person updating the record is the same as the caller. If the update is made by someone else, the label is removed. +This mechanism helps fulfillers quickly identify caller driven updates, enabling faster and more targeted responses. Additionally, it can be leveraged in reporting to track caller engagement. From 319fcbca634ceb1ee18ad9245ceac16d8851f326 Mon Sep 17 00:00:00 2001 From: SIVAMURUGANANDAM J <67639018+sivamuruganandam-coder@users.noreply.github.com> Date: Sun, 5 Oct 2025 09:57:43 +0530 Subject: [PATCH 03/21] Add Business rule: Add or remove tag to the ticket From 00cf6c0c4a929ded556557337723aeedb5431a35 Mon Sep 17 00:00:00 2001 From: SIVAMURUGANANDAM J <67639018+sivamuruganandam-coder@users.noreply.github.com> Date: Sun, 5 Oct 2025 10:10:48 +0530 Subject: [PATCH 04/21] Rename code.js to code.js --- .../code.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Server-Side Components/Business Rules/{Add or remove a tag from the ticket whenever the comments are updated => Add or remove a tag from the ticket whenever the comments are updated}/code.js (100%) diff --git a/Server-Side Components/Business Rules/Add or remove a tag from the ticket whenever the comments are updated /code.js b/Server-Side Components/Business Rules/Add or remove a tag from the ticket whenever the comments are updated/code.js similarity index 100% rename from Server-Side Components/Business Rules/Add or remove a tag from the ticket whenever the comments are updated /code.js rename to Server-Side Components/Business Rules/Add or remove a tag from the ticket whenever the comments are updated/code.js From b4694abefe2100b682598cc3639ad9ae957066d5 Mon Sep 17 00:00:00 2001 From: SIVAMURUGANANDAM J <67639018+sivamuruganandam-coder@users.noreply.github.com> Date: Sun, 5 Oct 2025 10:13:29 +0530 Subject: [PATCH 05/21] Rename README.md to README.md --- .../README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Server-Side Components/Business Rules/{Add or remove a tag from the ticket whenever the comments are updated => Add or remove a tag from the ticket whenever the comments are updated}/README.md (100%) diff --git a/Server-Side Components/Business Rules/Add or remove a tag from the ticket whenever the comments are updated /README.md b/Server-Side Components/Business Rules/Add or remove a tag from the ticket whenever the comments are updated/README.md similarity index 100% rename from Server-Side Components/Business Rules/Add or remove a tag from the ticket whenever the comments are updated /README.md rename to Server-Side Components/Business Rules/Add or remove a tag from the ticket whenever the comments are updated/README.md From bcba22df8aa61064c18f2197e680a42c7724f148 Mon Sep 17 00:00:00 2001 From: SIVAMURUGANANDAM J <67639018+sivamuruganandam-coder@users.noreply.github.com> Date: Sun, 5 Oct 2025 11:09:16 +0530 Subject: [PATCH 06/21] Adding new UI Action: Generate PDF --- .../UI Actions/Generate PDF/Script.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Client-Side Components/UI Actions/Generate PDF/Script.js diff --git a/Client-Side Components/UI Actions/Generate PDF/Script.js b/Client-Side Components/UI Actions/Generate PDF/Script.js new file mode 100644 index 0000000000..5c21ad5786 --- /dev/null +++ b/Client-Side Components/UI Actions/Generate PDF/Script.js @@ -0,0 +1,10 @@ +// UI Action: Generate PDF +// Table: Incident +// Condition: current.state=='6' //Resolved +// Onclick: generatePDF(); +// sysparm_view = pdf_export +function generatePDF() { + + var url = '/'+g_form.getTableName() + '.do?sys_id=' + g_form.getUniqueValue() + '&PDF&sysparm_view=pdf_export'; + top.window.open(url, '_blank'); +} From 72c0986e012ba23dbde31dec1a22d4ed33ec1a07 Mon Sep 17 00:00:00 2001 From: SIVAMURUGANANDAM J <67639018+sivamuruganandam-coder@users.noreply.github.com> Date: Sun, 5 Oct 2025 11:10:59 +0530 Subject: [PATCH 07/21] Adding new UI Action: Generate PDF --- Client-Side Components/UI Actions/Generate PDF/README.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Client-Side Components/UI Actions/Generate PDF/README.md diff --git a/Client-Side Components/UI Actions/Generate PDF/README.md b/Client-Side Components/UI Actions/Generate PDF/README.md new file mode 100644 index 0000000000..ca87f9f4b6 --- /dev/null +++ b/Client-Side Components/UI Actions/Generate PDF/README.md @@ -0,0 +1,6 @@ +Description: +This UI Action enables users to generate and download the current record in PDF format. It is particularly useful in the Incident table for PIR (Post-Incident Review) documents after resolution. + +Pre-requisite: +A dedicated form view must be created containing all relevant fields such as Resolution Code, Resolution Notes, Assignment Group, Assigned To, and others required for comprehensive reporting. +In this code, I've used the view name called 'pdf_export' which is already created in the Incident table From 5d9c06b7f435d7d8fb5f3871bb2283f99378f09a Mon Sep 17 00:00:00 2001 From: SIVAMURUGANANDAM J <67639018+sivamuruganandam-coder@users.noreply.github.com> Date: Sun, 5 Oct 2025 11:48:56 +0530 Subject: [PATCH 08/21] Adding new Background script: Bulk Update of Fulfillment Group References in Published KB Articles --- .../script.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Server-Side Components/Background Scripts/Bulk Update of Fulfillment Group References in Published KB Articles/script.js diff --git a/Server-Side Components/Background Scripts/Bulk Update of Fulfillment Group References in Published KB Articles/script.js b/Server-Side Components/Background Scripts/Bulk Update of Fulfillment Group References in Published KB Articles/script.js new file mode 100644 index 0000000000..3dce667c12 --- /dev/null +++ b/Server-Side Components/Background Scripts/Bulk Update of Fulfillment Group References in Published KB Articles/script.js @@ -0,0 +1,14 @@ +var old_reference = "Service desk"; // Old group name +var new_reference = "Help desk"; // New group name + +var regexPattern = new RegExp('(?is)'+ old_reference, 'gi'); // Building Regex to generate case-insensitive pattern + +var kb_article = new GlideRecord('kb_knowledge'); +kb_article.addEncodedQuery('workflow_state=published'); +kb_article.query(); +while(kb_article.next()){ + kb_article.text = kb_article.text.replace(regexPattern,new_reference); // Replacing the old group reference with the new group + kb_article.setWorkflow(false); + kb_article.update(); + gs.info('Updated Article: ' + kb_article.number); +} From 6f12dbdcbdbe0d73ef1be041ed60c7352db795ee Mon Sep 17 00:00:00 2001 From: SIVAMURUGANANDAM J <67639018+sivamuruganandam-coder@users.noreply.github.com> Date: Sun, 5 Oct 2025 11:50:01 +0530 Subject: [PATCH 09/21] Adding new Background script: Bulk Update of Fulfillment Group References in Published KB Articles --- .../README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Server-Side Components/Background Scripts/Bulk Update of Fulfillment Group References in Published KB Articles/README.md diff --git a/Server-Side Components/Background Scripts/Bulk Update of Fulfillment Group References in Published KB Articles/README.md b/Server-Side Components/Background Scripts/Bulk Update of Fulfillment Group References in Published KB Articles/README.md new file mode 100644 index 0000000000..7fa02ec5c2 --- /dev/null +++ b/Server-Side Components/Background Scripts/Bulk Update of Fulfillment Group References in Published KB Articles/README.md @@ -0,0 +1,2 @@ +Description: +This background script is used to automatically update the content of all published Knowledge Base articles by replacing outdated group references, ensuring consistency and relevance across documentation without the need to manually check out and edit each article From eec21a3b56c0380342842a7f94ca28c896147752 Mon Sep 17 00:00:00 2001 From: SIVAMURUGANANDAM J <67639018+sivamuruganandam-coder@users.noreply.github.com> Date: Sun, 5 Oct 2025 12:35:34 +0530 Subject: [PATCH 10/21] Delete Server-Side Components/Background Scripts/Bulk Update of Fulfillment Group References in Published KB Articles directory --- .../README.md | 2 -- .../script.js | 14 -------------- 2 files changed, 16 deletions(-) delete mode 100644 Server-Side Components/Background Scripts/Bulk Update of Fulfillment Group References in Published KB Articles/README.md delete mode 100644 Server-Side Components/Background Scripts/Bulk Update of Fulfillment Group References in Published KB Articles/script.js diff --git a/Server-Side Components/Background Scripts/Bulk Update of Fulfillment Group References in Published KB Articles/README.md b/Server-Side Components/Background Scripts/Bulk Update of Fulfillment Group References in Published KB Articles/README.md deleted file mode 100644 index 7fa02ec5c2..0000000000 --- a/Server-Side Components/Background Scripts/Bulk Update of Fulfillment Group References in Published KB Articles/README.md +++ /dev/null @@ -1,2 +0,0 @@ -Description: -This background script is used to automatically update the content of all published Knowledge Base articles by replacing outdated group references, ensuring consistency and relevance across documentation without the need to manually check out and edit each article diff --git a/Server-Side Components/Background Scripts/Bulk Update of Fulfillment Group References in Published KB Articles/script.js b/Server-Side Components/Background Scripts/Bulk Update of Fulfillment Group References in Published KB Articles/script.js deleted file mode 100644 index 3dce667c12..0000000000 --- a/Server-Side Components/Background Scripts/Bulk Update of Fulfillment Group References in Published KB Articles/script.js +++ /dev/null @@ -1,14 +0,0 @@ -var old_reference = "Service desk"; // Old group name -var new_reference = "Help desk"; // New group name - -var regexPattern = new RegExp('(?is)'+ old_reference, 'gi'); // Building Regex to generate case-insensitive pattern - -var kb_article = new GlideRecord('kb_knowledge'); -kb_article.addEncodedQuery('workflow_state=published'); -kb_article.query(); -while(kb_article.next()){ - kb_article.text = kb_article.text.replace(regexPattern,new_reference); // Replacing the old group reference with the new group - kb_article.setWorkflow(false); - kb_article.update(); - gs.info('Updated Article: ' + kb_article.number); -} From c0c1d1e01c2bbaec8ecb4ac2276644b59b3b0680 Mon Sep 17 00:00:00 2001 From: SIVAMURUGANANDAM J <67639018+sivamuruganandam-coder@users.noreply.github.com> Date: Sun, 5 Oct 2025 13:47:03 +0530 Subject: [PATCH 11/21] Update Script.js --- Client-Side Components/UI Actions/Generate PDF/Script.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Client-Side Components/UI Actions/Generate PDF/Script.js b/Client-Side Components/UI Actions/Generate PDF/Script.js index 5c21ad5786..96e64f03f9 100644 --- a/Client-Side Components/UI Actions/Generate PDF/Script.js +++ b/Client-Side Components/UI Actions/Generate PDF/Script.js @@ -1,10 +1,9 @@ // UI Action: Generate PDF // Table: Incident // Condition: current.state=='6' //Resolved -// Onclick: generatePDF(); +// Client true // sysparm_view = pdf_export -function generatePDF() { - +function onClick(g_form) { var url = '/'+g_form.getTableName() + '.do?sys_id=' + g_form.getUniqueValue() + '&PDF&sysparm_view=pdf_export'; top.window.open(url, '_blank'); } From d3310f4929d67f119160a7422acbce539dbaed31 Mon Sep 17 00:00:00 2001 From: SIVAMURUGANANDAM J <67639018+sivamuruganandam-coder@users.noreply.github.com> Date: Sun, 5 Oct 2025 13:50:06 +0530 Subject: [PATCH 12/21] Update README.md --- Client-Side Components/UI Actions/Generate PDF/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Client-Side Components/UI Actions/Generate PDF/README.md b/Client-Side Components/UI Actions/Generate PDF/README.md index ca87f9f4b6..6e0f5810f8 100644 --- a/Client-Side Components/UI Actions/Generate PDF/README.md +++ b/Client-Side Components/UI Actions/Generate PDF/README.md @@ -1,5 +1,6 @@ Description: -This UI Action enables users to generate and download the current record in PDF format. It is particularly useful in the Incident table for PIR (Post-Incident Review) documents after resolution. +This UI Action enables users to generate and download the current record in PDF format from the workspaces. It is particularly useful in the Incident table for PIR (Post-Incident Review) documents after resolution. +Currenty we don't have any option to export the record in the PDF fromat from Workspace. Users must go to the native/classic view to export the record. Pre-requisite: A dedicated form view must be created containing all relevant fields such as Resolution Code, Resolution Notes, Assignment Group, Assigned To, and others required for comprehensive reporting. From ece6aeaa85938d9149b596b95d2af85b19e570e3 Mon Sep 17 00:00:00 2001 From: SIVAMURUGANANDAM J <67639018+sivamuruganandam-coder@users.noreply.github.com> Date: Sun, 5 Oct 2025 13:53:46 +0530 Subject: [PATCH 13/21] Update README.md --- Client-Side Components/UI Actions/Generate PDF/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client-Side Components/UI Actions/Generate PDF/README.md b/Client-Side Components/UI Actions/Generate PDF/README.md index 6e0f5810f8..c527cb58e0 100644 --- a/Client-Side Components/UI Actions/Generate PDF/README.md +++ b/Client-Side Components/UI Actions/Generate PDF/README.md @@ -1,6 +1,6 @@ Description: This UI Action enables users to generate and download the current record in PDF format from the workspaces. It is particularly useful in the Incident table for PIR (Post-Incident Review) documents after resolution. -Currenty we don't have any option to export the record in the PDF fromat from Workspace. Users must go to the native/classic view to export the record. +Currenty we don't have any option to export the record in the PDF format from Workspace. Users must go to the native/classic view to export the record. Pre-requisite: A dedicated form view must be created containing all relevant fields such as Resolution Code, Resolution Notes, Assignment Group, Assigned To, and others required for comprehensive reporting. From 409fd7d4af4ff6713f69c1bd1d4c36013a96ec7a Mon Sep 17 00:00:00 2001 From: SIVAMURUGANANDAM J <67639018+sivamuruganandam-coder@users.noreply.github.com> Date: Sun, 5 Oct 2025 15:02:11 +0530 Subject: [PATCH 14/21] Delete Client-Side Components/UI Actions/Generate PDF directory --- Client-Side Components/UI Actions/Generate PDF/README.md | 7 ------- Client-Side Components/UI Actions/Generate PDF/Script.js | 9 --------- 2 files changed, 16 deletions(-) delete mode 100644 Client-Side Components/UI Actions/Generate PDF/README.md delete mode 100644 Client-Side Components/UI Actions/Generate PDF/Script.js diff --git a/Client-Side Components/UI Actions/Generate PDF/README.md b/Client-Side Components/UI Actions/Generate PDF/README.md deleted file mode 100644 index c527cb58e0..0000000000 --- a/Client-Side Components/UI Actions/Generate PDF/README.md +++ /dev/null @@ -1,7 +0,0 @@ -Description: -This UI Action enables users to generate and download the current record in PDF format from the workspaces. It is particularly useful in the Incident table for PIR (Post-Incident Review) documents after resolution. -Currenty we don't have any option to export the record in the PDF format from Workspace. Users must go to the native/classic view to export the record. - -Pre-requisite: -A dedicated form view must be created containing all relevant fields such as Resolution Code, Resolution Notes, Assignment Group, Assigned To, and others required for comprehensive reporting. -In this code, I've used the view name called 'pdf_export' which is already created in the Incident table diff --git a/Client-Side Components/UI Actions/Generate PDF/Script.js b/Client-Side Components/UI Actions/Generate PDF/Script.js deleted file mode 100644 index 96e64f03f9..0000000000 --- a/Client-Side Components/UI Actions/Generate PDF/Script.js +++ /dev/null @@ -1,9 +0,0 @@ -// UI Action: Generate PDF -// Table: Incident -// Condition: current.state=='6' //Resolved -// Client true -// sysparm_view = pdf_export -function onClick(g_form) { - var url = '/'+g_form.getTableName() + '.do?sys_id=' + g_form.getUniqueValue() + '&PDF&sysparm_view=pdf_export'; - top.window.open(url, '_blank'); -} From 1bb5d45e75276b8cdccc978ecde2d5c2f0362d16 Mon Sep 17 00:00:00 2001 From: SIVAMURUGANANDAM J <67639018+sivamuruganandam-coder@users.noreply.github.com> Date: Sun, 5 Oct 2025 15:34:31 +0530 Subject: [PATCH 15/21] Create script.js --- .../script.js | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Server-Side Components/Script Includes/Convert base64 to Hex (Object GUID)/script.js diff --git a/Server-Side Components/Script Includes/Convert base64 to Hex (Object GUID)/script.js b/Server-Side Components/Script Includes/Convert base64 to Hex (Object GUID)/script.js new file mode 100644 index 0000000000..a076894cbe --- /dev/null +++ b/Server-Side Components/Script Includes/Convert base64 to Hex (Object GUID)/script.js @@ -0,0 +1,79 @@ +var LDAP_AD_Utils = Class.create(); +LDAP_AD_Utils.prototype = { + initialize: function() {}, + + base64ToHex: function(str) { + + var decoded = GlideStringUtil.base64DecodeAsBytes(str); + + var n = decoded.length; + + if (n < 16) { + + return ''; + + } + + var retVal = ''; + + retVal = retVal + this.prefixZeros(decoded[3] & 0xFF).toUpperCase(); + + retVal = retVal + this.prefixZeros(decoded[2] & 0xFF).toUpperCase(); + + retVal = retVal + this.prefixZeros(decoded[1] & 0xFF).toUpperCase(); + + retVal = retVal + this.prefixZeros(decoded[0] & 0xFF).toUpperCase(); + + retVal = retVal + '-'; + + retVal = retVal + this.prefixZeros(decoded[5] & 0xFF).toUpperCase(); + + retVal = retVal + this.prefixZeros(decoded[4] & 0xFF).toUpperCase(); + + retVal = retVal + '-'; + + retVal = retVal + this.prefixZeros(decoded[7] & 0xFF).toUpperCase(); + + retVal = retVal + this.prefixZeros(decoded[6] & 0xFF).toUpperCase(); + + retVal = retVal + '-'; + + retVal = retVal + this.prefixZeros(decoded[8] & 0xFF).toUpperCase(); + + retVal = retVal + this.prefixZeros(decoded[9] & 0xFF).toUpperCase(); + + retVal = retVal + '-'; + + retVal = retVal + this.prefixZeros(decoded[10] & 0xFF).toUpperCase(); + + retVal = retVal + this.prefixZeros(decoded[11] & 0xFF).toUpperCase(); + + retVal = retVal + this.prefixZeros(decoded[12] & 0xFF).toUpperCase(); + + retVal = retVal + this.prefixZeros(decoded[13] & 0xFF).toUpperCase(); + + retVal = retVal + this.prefixZeros(decoded[14] & 0xFF).toUpperCase(); + + retVal = retVal + this.prefixZeros(decoded[15] & 0xFF).toUpperCase(); + + return retVal.toLowerCase(); + + }, + + + prefixZeros: function(value) { + + if (value <= 0xF) { + + return '0' + value.toString(16); + + } else { + + return value.toString(16); + + } + + }, + + type: 'LDAP_AD_Utils' +}; From 843ff9a77a73aa83f33ce6ae16eb46d0fe29a8ea Mon Sep 17 00:00:00 2001 From: SIVAMURUGANANDAM J <67639018+sivamuruganandam-coder@users.noreply.github.com> Date: Sun, 5 Oct 2025 15:38:59 +0530 Subject: [PATCH 16/21] Create README.md --- .../README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Server-Side Components/Script Includes/Convert base64 to Hex (Object GUID)/README.md diff --git a/Server-Side Components/Script Includes/Convert base64 to Hex (Object GUID)/README.md b/Server-Side Components/Script Includes/Convert base64 to Hex (Object GUID)/README.md new file mode 100644 index 0000000000..8d7c0ee6e8 --- /dev/null +++ b/Server-Side Components/Script Includes/Convert base64 to Hex (Object GUID)/README.md @@ -0,0 +1,16 @@ +**Description:** +This Script Include converts a Base64-encoded Active Directory (AD) Object GUID into its corresponding hexadecimal format. +When importing AD objects from an on-premises directory using LDAP, the object GUIDs are typically stored in Base64 format. +However, in OOB integrations such as the AD V2 Spoke, the GUID must be provided in hexadecimal format. +This Script Include bridges that gap by decoding the Base64 string and converting it into the required hex representation. + +**Usage:** +Can be used in the LDAP Transofrm scripts to convert the base64 code to HEX code + +**Sample:** + +var base64Code ='ayn8QMpHEGezHQDdAQZi2g=='; +gs.print(new global.LDAP_AD_Utils().base64ToHex(base64Code)); + +**Output:** +40fc296b-47ca-6710-b31d-00dd010662da From 1071238561263d729fc6309f42a3537d2e9441d5 Mon Sep 17 00:00:00 2001 From: SIVAMURUGANANDAM J <67639018+sivamuruganandam-coder@users.noreply.github.com> Date: Sun, 5 Oct 2025 17:03:13 +0530 Subject: [PATCH 17/21] Create script.js --- .../script.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Server-Side Components/Script Includes/Calculate Due date using user defined schedules/script.js diff --git a/Server-Side Components/Script Includes/Calculate Due date using user defined schedules/script.js b/Server-Side Components/Script Includes/Calculate Due date using user defined schedules/script.js new file mode 100644 index 0000000000..99039b6298 --- /dev/null +++ b/Server-Side Components/Script Includes/Calculate Due date using user defined schedules/script.js @@ -0,0 +1,26 @@ +var CaclculateDueDate = Class.create(); +CaclculateDueDate.prototype = { + initialize: function() {}, + + calculateDueDate: function(date, days_to_add) { + var checkDate = new GlideDateTime(date); + var daysToAdd = days_to_add; + + + while (daysToAdd > 0) { + var sched = new GlideSchedule('c798c1dfc3907e1091ea5242b40131c8'); // Schedule record SYS_ID. Currently 9-5 Weekdays and Indian Public Holiday(excluded) schedule has been used + checkDate.addDaysLocalTime(1); + if (sched.isInSchedule(checkDate)) { + daysToAdd--; + + } else { + continue; + + } + } + + return checkDate.getValue(); + }, + + type: 'CaclculateDueDate' +}; From 9a9619b595e38d0f1f6786d58ce9230aac4a7726 Mon Sep 17 00:00:00 2001 From: SIVAMURUGANANDAM J <67639018+sivamuruganandam-coder@users.noreply.github.com> Date: Sun, 5 Oct 2025 17:05:46 +0530 Subject: [PATCH 18/21] Create README.md --- .../README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Server-Side Components/Script Includes/Calculate Due date using user defined schedules/README.md diff --git a/Server-Side Components/Script Includes/Calculate Due date using user defined schedules/README.md b/Server-Side Components/Script Includes/Calculate Due date using user defined schedules/README.md new file mode 100644 index 0000000000..81aa7d6440 --- /dev/null +++ b/Server-Side Components/Script Includes/Calculate Due date using user defined schedules/README.md @@ -0,0 +1,14 @@ +**Description:** +This Script Include calculates a future due date by adding a specified number of business days to a given start date, based on a defined schedule. +This can be used anywhere within the server side scripts like fix scripts, background scripts, UI Action (server script). + +**Pre-requisite:** +A schedule record with valid schedule entries should be created in the cmn_schedule table + +**Sample:** +var daysToAdd = 4; // No of days need to be added +var script = new CaclculateDueDate().calculateDueDate(new GlideDateTime(),daysToAdd); // Passing the current date and daysToAdd value to script include +gs.print(script); + +**Output:** +*** Script: 2025-10-09 11:23:34 From a3622f05b50ef509d6ddc354589830513baf910f Mon Sep 17 00:00:00 2001 From: SIVAMURUGANANDAM J <67639018+sivamuruganandam-coder@users.noreply.github.com> Date: Sun, 5 Oct 2025 18:16:17 +0530 Subject: [PATCH 19/21] Delete Server-Side Components/Script Includes/Calculate Due date using user defined schedules directory --- .../README.md | 14 ---------- .../script.js | 26 ------------------- 2 files changed, 40 deletions(-) delete mode 100644 Server-Side Components/Script Includes/Calculate Due date using user defined schedules/README.md delete mode 100644 Server-Side Components/Script Includes/Calculate Due date using user defined schedules/script.js diff --git a/Server-Side Components/Script Includes/Calculate Due date using user defined schedules/README.md b/Server-Side Components/Script Includes/Calculate Due date using user defined schedules/README.md deleted file mode 100644 index 81aa7d6440..0000000000 --- a/Server-Side Components/Script Includes/Calculate Due date using user defined schedules/README.md +++ /dev/null @@ -1,14 +0,0 @@ -**Description:** -This Script Include calculates a future due date by adding a specified number of business days to a given start date, based on a defined schedule. -This can be used anywhere within the server side scripts like fix scripts, background scripts, UI Action (server script). - -**Pre-requisite:** -A schedule record with valid schedule entries should be created in the cmn_schedule table - -**Sample:** -var daysToAdd = 4; // No of days need to be added -var script = new CaclculateDueDate().calculateDueDate(new GlideDateTime(),daysToAdd); // Passing the current date and daysToAdd value to script include -gs.print(script); - -**Output:** -*** Script: 2025-10-09 11:23:34 diff --git a/Server-Side Components/Script Includes/Calculate Due date using user defined schedules/script.js b/Server-Side Components/Script Includes/Calculate Due date using user defined schedules/script.js deleted file mode 100644 index 99039b6298..0000000000 --- a/Server-Side Components/Script Includes/Calculate Due date using user defined schedules/script.js +++ /dev/null @@ -1,26 +0,0 @@ -var CaclculateDueDate = Class.create(); -CaclculateDueDate.prototype = { - initialize: function() {}, - - calculateDueDate: function(date, days_to_add) { - var checkDate = new GlideDateTime(date); - var daysToAdd = days_to_add; - - - while (daysToAdd > 0) { - var sched = new GlideSchedule('c798c1dfc3907e1091ea5242b40131c8'); // Schedule record SYS_ID. Currently 9-5 Weekdays and Indian Public Holiday(excluded) schedule has been used - checkDate.addDaysLocalTime(1); - if (sched.isInSchedule(checkDate)) { - daysToAdd--; - - } else { - continue; - - } - } - - return checkDate.getValue(); - }, - - type: 'CaclculateDueDate' -}; From 9cc1867f3d69cb34746ba91b438cb48a723be8ff Mon Sep 17 00:00:00 2001 From: SIVAMURUGANANDAM J <67639018+sivamuruganandam-coder@users.noreply.github.com> Date: Sun, 5 Oct 2025 18:19:47 +0530 Subject: [PATCH 20/21] Create README.md --- .../README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Core ServiceNow APIs/GlideDateTime/Calculate Due date using user defined schedules/README.md diff --git a/Core ServiceNow APIs/GlideDateTime/Calculate Due date using user defined schedules/README.md b/Core ServiceNow APIs/GlideDateTime/Calculate Due date using user defined schedules/README.md new file mode 100644 index 0000000000..81aa7d6440 --- /dev/null +++ b/Core ServiceNow APIs/GlideDateTime/Calculate Due date using user defined schedules/README.md @@ -0,0 +1,14 @@ +**Description:** +This Script Include calculates a future due date by adding a specified number of business days to a given start date, based on a defined schedule. +This can be used anywhere within the server side scripts like fix scripts, background scripts, UI Action (server script). + +**Pre-requisite:** +A schedule record with valid schedule entries should be created in the cmn_schedule table + +**Sample:** +var daysToAdd = 4; // No of days need to be added +var script = new CaclculateDueDate().calculateDueDate(new GlideDateTime(),daysToAdd); // Passing the current date and daysToAdd value to script include +gs.print(script); + +**Output:** +*** Script: 2025-10-09 11:23:34 From 5a50f65679395b43406a1cbb34f91277722a757a Mon Sep 17 00:00:00 2001 From: SIVAMURUGANANDAM J <67639018+sivamuruganandam-coder@users.noreply.github.com> Date: Sun, 5 Oct 2025 18:20:07 +0530 Subject: [PATCH 21/21] Add files via upload --- .../script.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Core ServiceNow APIs/GlideDateTime/Calculate Due date using user defined schedules/script.js diff --git a/Core ServiceNow APIs/GlideDateTime/Calculate Due date using user defined schedules/script.js b/Core ServiceNow APIs/GlideDateTime/Calculate Due date using user defined schedules/script.js new file mode 100644 index 0000000000..99039b6298 --- /dev/null +++ b/Core ServiceNow APIs/GlideDateTime/Calculate Due date using user defined schedules/script.js @@ -0,0 +1,26 @@ +var CaclculateDueDate = Class.create(); +CaclculateDueDate.prototype = { + initialize: function() {}, + + calculateDueDate: function(date, days_to_add) { + var checkDate = new GlideDateTime(date); + var daysToAdd = days_to_add; + + + while (daysToAdd > 0) { + var sched = new GlideSchedule('c798c1dfc3907e1091ea5242b40131c8'); // Schedule record SYS_ID. Currently 9-5 Weekdays and Indian Public Holiday(excluded) schedule has been used + checkDate.addDaysLocalTime(1); + if (sched.isInSchedule(checkDate)) { + daysToAdd--; + + } else { + continue; + + } + } + + return checkDate.getValue(); + }, + + type: 'CaclculateDueDate' +};