You need to sign in to do that
Don't have an account?
Validation rule for preventing creation of record till 10 am the next business day
Need some assistance, I have a requirnment where in an employee has to be permitted to enter their timesheet data by the next working day by 10 AM EST, post which a validation rule should prevent them in entering / modifying the previous work day's timesheet.
The following validation does not seem to be working as expected. For instance Timesheet entered on Friday (May 5,2023) , should permit saving it on Next Monday (May 8,2023) but it prevents saving before 10 AM.
Also, it further does not allow a user to enter the timesheet for the work day (May 8, 2023) even after 10 AM.
Wondering if any one have dealt with similar scenario, what was the approach / what can we modify in the validation rule shared below.
AND( Krow__Timesheet__r.EVC_Employee_Id__c ='939', TEXT(Krow__Timesheet__r.Krow__Approval_Status__c) = '', /* If the timesheet is still not submitted */ $User.Id <> CreatedById, /* Checks if the user is not the case owner */ DATETIMEVALUE(TEXT(Krow__Date__c) + " 04:00:00") < ( /* Converts Krow__Date__c field to a datetime value and compares it to the next business day at 10 AM EST */ CASE( MOD(5 + WEEKDAY(TODAY() - 1), 7), /* Calculates the day of the week for yesterday's date */ 0, DATETIMEVALUE(TEXT(TODAY() - 2) + " 10:00:00"), /* If today is Sunday(0), sets the next business day to Monday */ 1, DATETIMEVALUE(TEXT(TODAY() - 1) + " 10:00:00"), /* If today is Monday(1), sets the next business day to Tuesday */ 2, DATETIMEVALUE(TEXT(TODAY() - 1) + " 10:00:00"), /* If today is Tuesday(2), sets the next business day to Wednesday */ 3, DATETIMEVALUE(TEXT(TODAY() - 1) + " 10:00:00"), /* If today is Wednesday(3), sets the next business day to Thursday */ 4, DATETIMEVALUE(TEXT(TODAY() - 1) + " 10:00:00"), /* If today is Thursday(4), sets the next business day to Friday */ 5, DATETIMEVALUE(TEXT(TODAY() + 3) + " 10:00:00"), /* If today is Friday (5), sets the next business day to Monday */ DATETIMEVALUE(TEXT(TODAY() + 2) + " 10:00:00") /* If today is Saturday (6), sets the next business day to Monday */ ) - (5/24) /* Subtracts 5 hours to adjust for EST time zone */ ) )Thanks,
Gary
I found the same requirement on Stack Exchange you can follow the Stack Exchange for the solution.
https://salesforce.stackexchange.com/questions/403310/apex-validation-to-prevent-user-to-enter-records-for-last-working-day-by-a-speci
Thanks.