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 fire

I have new validation rule which is created , it works perfectly fine whenever we create a new record but it doesn't work when we edit previously created records . First the previously edited records are edited and saved and again when i try to edit them that's when the rule works. 

Where am i doing wrong 
SubratSubrat (Salesforce Developers) 
Hello Janaki ,

Can you please share the rule via Screen shot .

Thank you.
Janaki Reddi 17Janaki Reddi 17
OR
(AND ( Wednesday_Date__c = TODAY ()+1 , ISNEW()),
(AND ( Thursday_Date__c = TODAY () + 2, OR(ISCHANGED( Thursday__c ), ISNEW()))),(AND ( Friday_Date__c = TODAY () + 3, OR(ISCHANGED( Friday__c ),ISNEW()))))
Shri RajShri Raj


The validation rule logic is written in such a way that it will only fire when the record is either new or a specific field has changed. The issue is that the validation rule is only triggering after the record has been saved, not upon an initial edit. To resolve this issue, you can modify the rule to use the ISCHANGED function for all relevant fields, instead of just the specific fields, to trigger the validation rule on initial edit:

OR(
AND( Wednesday_Date__c = TODAY() + 1, ISCHANGED(Wednesday_Date__c)),
AND( Thursday_Date__c = TODAY() + 2, ISCHANGED(Thursday_Date__c)),
AND( Friday_Date__c = TODAY() + 3, ISCHANGED(Friday_Date__c))
)


Alternatively, you could consider using a trigger, as it may provide more flexibility in terms of validating data and handling any errors.