Validation rule is not working as expected

validation-rule

I have created a validation rule whenever the picklist Field (status) is N/A I have to make another fields as not editable based on the picklist values .

Below is my validation rule :

AND(
ISPICKVAL( status__c,'N/A'),
ISCHANGED( NHPMS__Re_Admit__c ),
ISCHANGED( NHPMS__Discharge_Date__c ),
ISCHANGED( Next_Appointment__c )

)

I am able to change my Next appointment (pickList Field) and discharge date (Date Field)

Before Validation Rule
Before Validation Rule

After Validation Rule
After Validation Rule

Best Answer

Your current validation rule says the following

Block the user if the all of the following is true:

  1. Status__c = 'N/A'
  2. NHPMS__Re_Admit__c IS CHANGED
  3. NHPMS__Discharge_Date__c IS CHANGED
  4. Next_Appointment__c IS CHANGED

In your screenshot, only #1, #3, and #4 are true. You are not changing NHPMS__Re_Admit__c so the validation rule does not block you.

Based on your requirement, it sounds like you either:

  • Do not care if NHPMS__Re_Admit__c changes, in which case just remove it

or

  • Actually just want to fire if any of those fields change (not all of them together).

For that second scenario, you should leverage OR to denote that any of those fields changing meets criteria

AND(
    ISPICKVAL( status__c,'N/A'),
    OR(
        ISCHANGED( NHPMS__Re_Admit__c ),
        ISCHANGED( NHPMS__Discharge_Date__c ),
        ISCHANGED( Next_Appointment__c )
    )
)

The above will now block the user if the following is true:

  1. Status__c = 'N/A'
  2. Any single one of the 3 fields is changing
Related Topic