1

I am trying to create a validation rule that prevents a lookup field from being updated/changed when a checkbox on the referenced lookup record is true. I tried to reference the field using the _r but it didn't work.

I then tried using a formula field SIM_Card_2_calc__c and it doesn't work. The lookup field is SIM_Card_2__c. I want the rule to trigger only when the formula field is False. When it is true, I want the users to be able to change the field or make it blank.

AND(
    RecordType.DeveloperName = "POS",
    ISPICKVAL(Status , 'Consumed') ,
    SIM_required__c = TRUE,
    SIM_Card_2_calc__c = FALSE,
    NOT(ISBLANK(PRIORVALUE(SIM_Card_2__c ))),
    ISCHANGED(SIM_Card_2__c ),
    NOT(ISNEW())
)

1 Answer 1

1

As a default, a validation rule checks the 'new' situation, i.e. it will be checking if the new lookup record has the checkbox field filled. In order to look at 'old' data, you need to use the PRIORVALUE

You indeed cannot directly reference a related record's priorvalue in a validation rule. But you should be able to check for the formula field's priorvalue (and check for 'TRUE' because the validation rule should contain the criteria that trigger the validation error):

AND(
    RecordType.DeveloperName = "POS",
    ISPICKVAL(Status , 'Consumed') ,
    SIM_required__c = TRUE,
    PRIORVALUE(SIM_Card_2_calc__c) = TRUE,
    NOT(ISBLANK(PRIORVALUE(SIM_Card_2__c ))),
    ISCHANGED(SIM_Card_2__c ),
    NOT(ISNEW())
)

(This is assuming your formula field just contains a 'copy' of the value on the related record)

1
  • THANK YOU!! I spent a little too long trying to figure this out
    – Abby
    Jan 10, 2023 at 15:07

You must log in to answer this question.

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