function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Janaki Reddi 17Janaki Reddi 17 

Validation Rule on Locking Checkbox for a Week basing on a Date Field

We have a Reservation Object which has Check Box Fileds for the reservations( Monday , Tuesday , Wednesday etc) and we have a corresponding date field for which they made reservations ( monday date , tuesday date etc) . 

Department wants no user to make a reservation one week prior or make changes . If a user wants to make reservation for 1/9/23 , the latest they would be allowed is 1/1/23 to make reservation and on 1/8/23 they will be allowed to make any cancelations , that is unchecking the reservation value.

As a first step i wrote a validation rule 
OR (AND( Monday_Date__c  =  TODAY ()  +7 , ISCHANGED( Monday__c)),
AND(  Tuesday_Date__c  =  TODAY ()  +7 , ISCHANGED(  Tuesday__c ))

the above rule is not letting anyone to make changes for 1/9 reservation today but i need to check whether the rule will still work tomorrow 

the rule doesn't work when a new record is created. 

Please sugges where am i doing wrong
 
AnkaiahAnkaiah (Salesforce Developers) 
Hi Janaki,

Can you clarify the below.

ex : user  has booked a ticket on 1/10/2023 and he can't able to change/cancell the ticket one week before i.e from 3rd jan onwards?

Thanks!!
Janaki Reddi 17Janaki Reddi 17
Yes , to make it more simpler we want the fields to be locked for in between dates that is for monday reservation ( 1/9/23 it needs to be locked from 1/2/23 to 1/8/23)

User-added image
Janaki Reddi 17Janaki Reddi 17
The above monday date is a hidden formula field calculated from "from the week begining" , Will i be able to achieve both requirements of locking and unlocking ( again this will be hiddne fields) if i have a lock date and unlock date using validation rule .