0

I want to create a validation rule to prevent a field called Booking Type from being changed back to the value "--None--" when it's prior value is any value except for "--None--" AND when a position (the custom object) has been assigned (checkbox field). Here is the what I have so far but it's throwing me a syntax error that I can't figure out:

AND(
ISCHANGED(Person_Booking_Type__c),
NOT(ISPICKVAL(PRIORVALUE(Person_Booking_Type__c),"--None--")),
ISPICKVAL(Person_Booking_Type__c),"--None--"),
Assigned__c = True

1 Answer 1

0

As usual, indenting formulas as if they were code helps to identify issues.

Applying that to your formula so far:

AND(
    ISCHANGED(Person_Booking_Type__c),
    NOT(
        ISPICKVAL(
            PRIORVALUE(Person_Booking_Type__c),
            "--None--"
        )
    ),
    ISPICKVAL(Person_Booking_Type__c),"--None--"
),
Assigned__c = True

Your formula here is closing the final ISPICKVAL() too soon, and fails to close the AND(). The syntactically correct version would be

AND(
    ISCHANGED(Person_Booking_Type__c),
    NOT(
        ISPICKVAL(
            PRIORVALUE(Person_Booking_Type__c),
            "--None--"
        )
    ),
    ISPICKVAL(Person_Booking_Type__c,"--None--"),
    Assigned__c = True
)
2
  • Thank you, that seems to have fixed the syntax issue. However, for some reason in my tests the validation rule doesn't seem to prevent the desired scenario that I outlined above. Commented Nov 18, 2021 at 17:07
  • The issue was on my end. Apparently the sfdc lightning picklist value of "--None--" is not really picklist value, rather the value is blank once it's saved, so "" worked. Commented Nov 18, 2021 at 19:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .