From acdfcd9df22e7eecf511a73f9d940beac8c1d77c Mon Sep 17 00:00:00 2001 From: HackoDev1530 <92592691+HackoDev1530@users.noreply.github.com> Date: Tue, 7 Oct 2025 15:15:21 -0500 Subject: [PATCH 01/14] Create README.md --- .../Client Scripts/Auto-Populate Planned End Date/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Client-Side Components/Client Scripts/Auto-Populate Planned End Date/README.md diff --git a/Client-Side Components/Client Scripts/Auto-Populate Planned End Date/README.md b/Client-Side Components/Client Scripts/Auto-Populate Planned End Date/README.md new file mode 100644 index 0000000000..1ed4eaaa20 --- /dev/null +++ b/Client-Side Components/Client Scripts/Auto-Populate Planned End Date/README.md @@ -0,0 +1 @@ +An onChange client script that calls the script includes that adds the X number of business days to the planned start date, and autopopulates the planned end date based on the type From 1e9c7fb2f4c34b4375bfb65f44aae218539b53d8 Mon Sep 17 00:00:00 2001 From: HackoDev1530 <92592691+HackoDev1530@users.noreply.github.com> Date: Tue, 7 Oct 2025 15:32:57 -0500 Subject: [PATCH 02/14] Create autoPopulatePlannedEndDate.js --- .../autoPopulatePlannedEndDate.js | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Auto-Populate Planned End Date/autoPopulatePlannedEndDate.js diff --git a/Client-Side Components/Client Scripts/Auto-Populate Planned End Date/autoPopulatePlannedEndDate.js b/Client-Side Components/Client Scripts/Auto-Populate Planned End Date/autoPopulatePlannedEndDate.js new file mode 100644 index 0000000000..a6a97f6d60 --- /dev/null +++ b/Client-Side Components/Client Scripts/Auto-Populate Planned End Date/autoPopulatePlannedEndDate.js @@ -0,0 +1,25 @@ +//Client script +//Table: Change Request +//UI Type: All +//Type: onChange +//Field: Planned Start Date +function onChange(control, oldValue, newValue, isLoading, isTemplate) { + if (isLoading || newValue === '') { + return; + } + var daysToAdd; + if(g_form.getValue('type') =='standard' || g_form.getValue('type') =='normal') + daysToAdd = 3; + else if(g_form.getValue('type') =='emergency') + daysToAdd = 1; + var ga = new GlideAjax("addBusinessDays"); //Calling the script include + ga.addParam('sysparm_name', 'addDays'); + ga.addParam('sysparm_days', daysToAdd); + ga.addParam('sysparm_date', newValue); + ga.getXML(processResponse); + + function processResponse(response) { + var answer = response.responseXML.documentElement.getAttribute("answer").toString(); + g_form.setValue('end_date', answer); + } +} From 89a965b4be196ec82aa52d76985729b23bc1eb0f Mon Sep 17 00:00:00 2001 From: HackoDev1530 <92592691+HackoDev1530@users.noreply.github.com> Date: Tue, 7 Oct 2025 15:35:40 -0500 Subject: [PATCH 03/14] Create README.md --- .../Script Includes/Add Business Days/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Server-Side Components/Script Includes/Add Business Days/README.md diff --git a/Server-Side Components/Script Includes/Add Business Days/README.md b/Server-Side Components/Script Includes/Add Business Days/README.md new file mode 100644 index 0000000000..ae47e88283 --- /dev/null +++ b/Server-Side Components/Script Includes/Add Business Days/README.md @@ -0,0 +1 @@ +A script includes adds number of business days using the OOB 8-5 weekdays excluding holidays schedule From c09af7d42693d04d614a8433cd560b033c40416e Mon Sep 17 00:00:00 2001 From: HackoDev1530 <92592691+HackoDev1530@users.noreply.github.com> Date: Tue, 7 Oct 2025 15:38:17 -0500 Subject: [PATCH 04/14] Create addBusinessDays.js --- .../Add Business Days/addBusinessDays.js | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Server-Side Components/Script Includes/Add Business Days/addBusinessDays.js diff --git a/Server-Side Components/Script Includes/Add Business Days/addBusinessDays.js b/Server-Side Components/Script Includes/Add Business Days/addBusinessDays.js new file mode 100644 index 0000000000..717cfc0fc5 --- /dev/null +++ b/Server-Side Components/Script Includes/Add Business Days/addBusinessDays.js @@ -0,0 +1,34 @@ + +var addBusinessDays = Class.create(); +var schedule = new GlideSchedule('090eecae0a0a0b260077e1dfa71da828'); +addBusinessDays.prototype = Object.extendsObject(global.AbstractAjaxProcessor, { + + addDays: function() { + var days = parseInt(this.getParameter("sysparm_days")); + var boh = this.getParameter("basedOnHours"); + var startDate = new GlideDateTime(this.getParameter("sysparm_date").toString()); + + + var sd = startDate; + startDate = startDate.getDate(); + var time = sd.getTime().getByFormat('HH:mm:ss'); + + + var dur = new GlideDuration(60 * 60 * 1000 * (days * 9)); + schedule = new GlideSchedule('090eecae0a0a0b260077e1dfa71da828'); //sys_id of OOB schedule 8-5 weekdays excluding holidays + var end = schedule.add(startDate, dur); + var endDate = end.getDate().getByFormat("MM/dd/yyyy"); + var endDateTime = endDate + ' ' + time; + + return endDateTime.toString(); + + + }, + + + + + + + type: 'addBusinessDays' +}); From d76813e6fd12bae6add1ccf22b08600628a6461d Mon Sep 17 00:00:00 2001 From: HackoDev1530 <92592691+HackoDev1530@users.noreply.github.com> Date: Tue, 7 Oct 2025 15:40:49 -0500 Subject: [PATCH 05/14] Update addBusinessDays.js --- .../Add Business Days/addBusinessDays.js | 30 +++++-------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/Server-Side Components/Script Includes/Add Business Days/addBusinessDays.js b/Server-Side Components/Script Includes/Add Business Days/addBusinessDays.js index 717cfc0fc5..7c926b1d3d 100644 --- a/Server-Side Components/Script Includes/Add Business Days/addBusinessDays.js +++ b/Server-Side Components/Script Includes/Add Business Days/addBusinessDays.js @@ -1,34 +1,20 @@ - +// Takes the number of days as a parameter var addBusinessDays = Class.create(); var schedule = new GlideSchedule('090eecae0a0a0b260077e1dfa71da828'); addBusinessDays.prototype = Object.extendsObject(global.AbstractAjaxProcessor, { addDays: function() { var days = parseInt(this.getParameter("sysparm_days")); - var boh = this.getParameter("basedOnHours"); - var startDate = new GlideDateTime(this.getParameter("sysparm_date").toString()); - - - var sd = startDate; - startDate = startDate.getDate(); - var time = sd.getTime().getByFormat('HH:mm:ss'); - - + var startDate = new GlideDateTime(this.getParameter("sysparm_date").toString()); + var sd = startDate; + startDate = startDate.getDate(); + var time = sd.getTime().getByFormat('HH:mm:ss'); var dur = new GlideDuration(60 * 60 * 1000 * (days * 9)); schedule = new GlideSchedule('090eecae0a0a0b260077e1dfa71da828'); //sys_id of OOB schedule 8-5 weekdays excluding holidays var end = schedule.add(startDate, dur); - var endDate = end.getDate().getByFormat("MM/dd/yyyy"); - var endDateTime = endDate + ' ' + time; - - return endDateTime.toString(); - - + var endDate = end.getDate().getByFormat("MM/dd/yyyy"); + var endDateTime = endDate + ' ' + time; + return endDateTime.toString(); }, - - - - - - type: 'addBusinessDays' }); From e2f93b9d8b45f248b33a5ccb7dee466b657d8e73 Mon Sep 17 00:00:00 2001 From: HackoDev1530 <92592691+HackoDev1530@users.noreply.github.com> Date: Tue, 7 Oct 2025 15:42:32 -0500 Subject: [PATCH 06/14] Update README.md --- .../Script Includes/Add Business Days/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Server-Side Components/Script Includes/Add Business Days/README.md b/Server-Side Components/Script Includes/Add Business Days/README.md index ae47e88283..7323d718d9 100644 --- a/Server-Side Components/Script Includes/Add Business Days/README.md +++ b/Server-Side Components/Script Includes/Add Business Days/README.md @@ -1 +1,2 @@ -A script includes adds number of business days using the OOB 8-5 weekdays excluding holidays schedule +The script includes adds number of business days using the OOB 8-5 weekdays excluding holidays schedule +The script includes the sys_id of the OOB schedule, calculates the number of business days, and returns the date. From 2b5d6a8e305a5bb714d5ec725a1e48703e37941f Mon Sep 17 00:00:00 2001 From: HackoDev1530 <92592691+HackoDev1530@users.noreply.github.com> Date: Tue, 7 Oct 2025 15:43:17 -0500 Subject: [PATCH 07/14] Update addBusinessDays.js --- .../Script Includes/Add Business Days/addBusinessDays.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Server-Side Components/Script Includes/Add Business Days/addBusinessDays.js b/Server-Side Components/Script Includes/Add Business Days/addBusinessDays.js index 7c926b1d3d..1885a18423 100644 --- a/Server-Side Components/Script Includes/Add Business Days/addBusinessDays.js +++ b/Server-Side Components/Script Includes/Add Business Days/addBusinessDays.js @@ -1,4 +1,4 @@ -// Takes the number of days as a parameter +// Takes the number of days as a parameter, and the start date var addBusinessDays = Class.create(); var schedule = new GlideSchedule('090eecae0a0a0b260077e1dfa71da828'); addBusinessDays.prototype = Object.extendsObject(global.AbstractAjaxProcessor, { From 56df78f86f3edb55e9839bbb2725c9c7d3a7b0c3 Mon Sep 17 00:00:00 2001 From: HackoDev1530 <92592691+HackoDev1530@users.noreply.github.com> Date: Tue, 7 Oct 2025 15:43:51 -0500 Subject: [PATCH 08/14] Update README.md --- .../Script Includes/Add Business Days/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Server-Side Components/Script Includes/Add Business Days/README.md b/Server-Side Components/Script Includes/Add Business Days/README.md index 7323d718d9..a2fa89aa4c 100644 --- a/Server-Side Components/Script Includes/Add Business Days/README.md +++ b/Server-Side Components/Script Includes/Add Business Days/README.md @@ -1,2 +1,2 @@ -The script includes adds number of business days using the OOB 8-5 weekdays excluding holidays schedule +The client callable script includes adds number of business days using the OOB 8-5 weekdays excluding holidays schedule The script includes the sys_id of the OOB schedule, calculates the number of business days, and returns the date. From 47a15c930cc3edd25bc04a215599e09a98b5728e Mon Sep 17 00:00:00 2001 From: HackoDev1530 <92592691+HackoDev1530@users.noreply.github.com> Date: Tue, 7 Oct 2025 15:44:29 -0500 Subject: [PATCH 09/14] Update addBusinessDays.js --- .../Script Includes/Add Business Days/addBusinessDays.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Server-Side Components/Script Includes/Add Business Days/addBusinessDays.js b/Server-Side Components/Script Includes/Add Business Days/addBusinessDays.js index 1885a18423..0e7b1957ea 100644 --- a/Server-Side Components/Script Includes/Add Business Days/addBusinessDays.js +++ b/Server-Side Components/Script Includes/Add Business Days/addBusinessDays.js @@ -1,4 +1,6 @@ // Takes the number of days as a parameter, and the start date +//Name: addBusinessDays +//Client Callable: checked var addBusinessDays = Class.create(); var schedule = new GlideSchedule('090eecae0a0a0b260077e1dfa71da828'); addBusinessDays.prototype = Object.extendsObject(global.AbstractAjaxProcessor, { From a6f8a0c6d29823ca643f4403f11f9b7522262073 Mon Sep 17 00:00:00 2001 From: HackoDev1530 <92592691+HackoDev1530@users.noreply.github.com> Date: Tue, 7 Oct 2025 15:46:43 -0500 Subject: [PATCH 10/14] Update autoPopulatePlannedEndDate.js --- .../autoPopulatePlannedEndDate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client-Side Components/Client Scripts/Auto-Populate Planned End Date/autoPopulatePlannedEndDate.js b/Client-Side Components/Client Scripts/Auto-Populate Planned End Date/autoPopulatePlannedEndDate.js index a6a97f6d60..70b4930070 100644 --- a/Client-Side Components/Client Scripts/Auto-Populate Planned End Date/autoPopulatePlannedEndDate.js +++ b/Client-Side Components/Client Scripts/Auto-Populate Planned End Date/autoPopulatePlannedEndDate.js @@ -12,7 +12,7 @@ function onChange(control, oldValue, newValue, isLoading, isTemplate) { daysToAdd = 3; else if(g_form.getValue('type') =='emergency') daysToAdd = 1; - var ga = new GlideAjax("addBusinessDays"); //Calling the script include + var ga = new GlideAjax("addBusinessDays"); //Calling the add business days script include, which is in the Server-Side Components/Script Includes/Add Business Days/addBusinessDays.js ga.addParam('sysparm_name', 'addDays'); ga.addParam('sysparm_days', daysToAdd); ga.addParam('sysparm_date', newValue); From 43baef9edaddfafd2c497361d7fb090596f87e67 Mon Sep 17 00:00:00 2001 From: HackoDev1530 <92592691+HackoDev1530@users.noreply.github.com> Date: Tue, 7 Oct 2025 16:28:42 -0500 Subject: [PATCH 11/14] Update README.md --- .../Client Scripts/Auto-Populate Planned End Date/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Client-Side Components/Client Scripts/Auto-Populate Planned End Date/README.md b/Client-Side Components/Client Scripts/Auto-Populate Planned End Date/README.md index 1ed4eaaa20..0cb4c2c3fa 100644 --- a/Client-Side Components/Client Scripts/Auto-Populate Planned End Date/README.md +++ b/Client-Side Components/Client Scripts/Auto-Populate Planned End Date/README.md @@ -1 +1,2 @@ -An onChange client script that calls the script includes that adds the X number of business days to the planned start date, and autopopulates the planned end date based on the type +An onChange client script that calls the script includes one that adds the specified number of business days to the planned start date and autopopulates the planned end date based on the type. +For the client callable script include refer to the README file in the Add Business Days Script include folder. From 03b13488d10658f627cc974f9a7108c2b3d7017e Mon Sep 17 00:00:00 2001 From: HackoDev1530 <92592691+HackoDev1530@users.noreply.github.com> Date: Tue, 7 Oct 2025 16:30:09 -0500 Subject: [PATCH 12/14] Update README.md --- .../Script Includes/Add Business Days/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Server-Side Components/Script Includes/Add Business Days/README.md b/Server-Side Components/Script Includes/Add Business Days/README.md index a2fa89aa4c..2fa3190e63 100644 --- a/Server-Side Components/Script Includes/Add Business Days/README.md +++ b/Server-Side Components/Script Includes/Add Business Days/README.md @@ -1,2 +1,3 @@ -The client callable script includes adds number of business days using the OOB 8-5 weekdays excluding holidays schedule +The client callable script includes adds number of business days using the OOB 8-5 weekdays, excluding holidays, schedule The script includes the sys_id of the OOB schedule, calculates the number of business days, and returns the date. +For the onChange client script, refer to the README file in the Auto-POpulate Planned End Date client script folder. From afa52c53d9c6ba29424a7cda700fe7626ec441d9 Mon Sep 17 00:00:00 2001 From: Earl Duque <31702109+earlduque@users.noreply.github.com> Date: Tue, 7 Oct 2025 18:16:09 -0700 Subject: [PATCH 13/14] Update README.md --- .../Client Scripts/Auto-Populate Planned End Date/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client-Side Components/Client Scripts/Auto-Populate Planned End Date/README.md b/Client-Side Components/Client Scripts/Auto-Populate Planned End Date/README.md index 0cb4c2c3fa..5b6175153d 100644 --- a/Client-Side Components/Client Scripts/Auto-Populate Planned End Date/README.md +++ b/Client-Side Components/Client Scripts/Auto-Populate Planned End Date/README.md @@ -1,2 +1,2 @@ An onChange client script that calls the script includes one that adds the specified number of business days to the planned start date and autopopulates the planned end date based on the type. -For the client callable script include refer to the README file in the Add Business Days Script include folder. +For the client callable script include refer to the README file in the Add Business Days Script include folder. Link: [Add Business Days Script Include](/Server-Side%20Components/Script%20Includes/Add%20Business%20Days/README.md) From 50b57413127865aea16746680655b658e85ae6d0 Mon Sep 17 00:00:00 2001 From: Earl Duque <31702109+earlduque@users.noreply.github.com> Date: Tue, 7 Oct 2025 18:17:31 -0700 Subject: [PATCH 14/14] Update README.md --- .../Script Includes/Add Business Days/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Server-Side Components/Script Includes/Add Business Days/README.md b/Server-Side Components/Script Includes/Add Business Days/README.md index 2fa3190e63..b769e9b42f 100644 --- a/Server-Side Components/Script Includes/Add Business Days/README.md +++ b/Server-Side Components/Script Includes/Add Business Days/README.md @@ -1,3 +1,3 @@ The client callable script includes adds number of business days using the OOB 8-5 weekdays, excluding holidays, schedule The script includes the sys_id of the OOB schedule, calculates the number of business days, and returns the date. -For the onChange client script, refer to the README file in the Auto-POpulate Planned End Date client script folder. +For the onChange client script, refer to the README file in the Auto-POpulate Planned End Date client script folder. Link: [Auto-Populate Planned End Date Client Script](/Client-Side%20Components/Client%20Scripts/Auto-Populate%20Planned%20End%20Date/README.md)