I want to write a validation rule on the Opportunity record - Condition:- User can only check the contracted checkbox if the opportunity stage is closed won and primary quote (lookup field) - status field is approved. Can someone help me.

I wrote this, but this doesn't work

    SBQQ__Contracted__c = TRUE,
    TEXT(StageName) <> "Closed",
    TEXT(SBQQ__PrimaryQuote__r.SBQQ__Status__c) <> "Approved"

If I consider only opp stagename as condition - it works.. but once I add the primary quote condition my logic fails

1 Answer 1


I'm assuming that SBQQ_PrimaryQuote__c is a lookup field on the Opportunity, and that this field is populated.

Remember the first law of validation rules

validation rules don't tell you when your data is valid.
They tell you when your data is invalid.

If your condition for data to be valid is
when SBQQ__Contracted__c is true, Opp stage must be closed and primary quote must be approved

then the condition for when data is invalid is
when SBQQ__Contracted__c is true, and Opp stage is not closed **or** primary quote is not approved

From basic boolean algebra, De Morgan's law states that NOT(AND(X, Y)) === OR(NOT(X), NOT(Y)). That's why the invalid state swaps the inner "and" with an "or"

So your formula should be

    /* No need to compare a checkbox to true/false, because it's already boolean */
        TEXT(StageName) != "Closed",
        TEXT(SBQQ__PrimaryQuote__r.SBQQ__Status__c) != "Approved"

You must log in to answer this question.

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