From df1c9dcf0f4b20579cba13effd9ef9e1df5d4465 Mon Sep 17 00:00:00 2001 From: Indra-kolge <123245160+Indra-kolge@users.noreply.github.com> Date: Fri, 17 Oct 2025 17:24:19 +0530 Subject: [PATCH 1/2] script.js --- .../Reinstate Error status/script.js | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Reinstate Error status/script.js diff --git a/Client-Side Components/Client Scripts/Reinstate Error status/script.js b/Client-Side Components/Client Scripts/Reinstate Error status/script.js new file mode 100644 index 0000000000..a328df1543 --- /dev/null +++ b/Client-Side Components/Client Scripts/Reinstate Error status/script.js @@ -0,0 +1,39 @@ +function onSubmit() { + // Cutoff time for submission in CST. + var cutoffTime = "20:00:00"; + + // Get the current date and time in CST + var currentDate = new Date(); + var currentCSTDate = new Date( + currentDate.toLocaleString("en-US", { + timeZone: "America/Chicago" + }) + ); + + // Get time from current CST date + var currentCSTTime = currentCSTDate.toTimeString().substring(0, 8); + + // Get last day of the month + var dayOfMonth = currentCSTDate.getDate(); + var lastDayOfMonth = new Date( + currentCSTDate.getFullYear(), + currentCSTDate.getMonth() + 1, + 0 + ).getDate(); + + if ((dayOfMonth === 16 || dayOfMonth === lastDayOfMonth) && currentCSTTime > cutoffTime) { + var workDate = g_form.getValue("work_date"); + + if (workDate) { + var formattedWorkDate = new Date(workDate + "T00:00:00"); + // If work_date is on or before current date, block submission + if (formattedWorkDate <= currentCSTDate) { + g_form.addErrorMessage( + "The time period closed for time submission at 8:00 PM CST. Time must be billed in the next time period." + ": " + lastDayOfMonth + ); + return false; + } + } + } + return true; +} From 2d430532ce56d58a7d805f37648b28067b14fc0d Mon Sep 17 00:00:00 2001 From: Indra-kolge <123245160+Indra-kolge@users.noreply.github.com> Date: Fri, 17 Oct 2025 17:26:54 +0530 Subject: [PATCH 2/2] README.md --- .../Reinstate Error status/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Reinstate Error status/README.md diff --git a/Client-Side Components/Client Scripts/Reinstate Error status/README.md b/Client-Side Components/Client Scripts/Reinstate Error status/README.md new file mode 100644 index 0000000000..36493cb2f5 --- /dev/null +++ b/Client-Side Components/Client Scripts/Reinstate Error status/README.md @@ -0,0 +1,14 @@ +Table: Time Worked [task_time_worked] +Type: onsubmit + +#Objective : +Ensure that time entries (represented by the work_date field) are not submitted after 8:00 PM CST on two key dates: +The 16th of the month and The last day of the month +If a user tries to submit time for a current or past date after the cut-off time, the submission is blocked and a clear error message is displayed. + +#Business Scenario +Imagine a consulting firm where employees log billable hours against customer cases. There are internal controls in place that lock the timekeeping system after a certain cut-off time to ensure accurate payroll and billing. + +The finance department requires that: +On the 16th and last day of each month, submissions must be in before 8:00 PM CST. +If employees miss the deadline, they can only log time for future dates (not today or the past).