0
AND(
    NOT(ISBLANK(Account.Name)),
    OR(
        AND(
            ISPICKVAL(LeadSource, "Web"),
            Lead_Source_Details__c <> ""
        ),
        AND(
            ISPICKVAL(LeadSource, "Referral"),
            NOT(ISBLANK(Referral_Source__c))
        )
    ),
    OR(
        Amount > 1000,
        AND(
            ISPICKVAL(Type, "New Business"),
            Probability > 50
        )
    ),
    NOT(
        AND(
            ISNEW(),
            ISCHANGED(Status)
        ),
        NOT(ISBLANK(Email))
    )

Additional criteria are being added to the section at the end to ensure that the contact and leadsource fields are not blank

    NOT(
        AND(
            ISNEW(),
            ISCHANGED(Status)
        ),
        NOT(ISBLANK(Email)),
        NOT(ISBLANK(Contact__c)),
        NOT(ISBLANK(LeadSource))
    )
1
  • You are allowed literally hundreds of validation rules per object. Writing one long validation rule is not only more complicated, but it provides a worse user experience, since the user can no longer determine which field(s) are incorrect.
    – sfdcfox
    Mar 18 at 15:52

1 Answer 1

0

Hello It looks like the syntax error in the initial validation rule is caused by a missing closing parenthesis after the last NOT function. Here's the corrected version:

AND(
    NOT(ISBLANK(Account.Name)),
    OR(
        AND(
            ISPICKVAL(LeadSource, "Web"),
            Lead_Source_Details__c <> ""
        ),
        AND(
            ISPICKVAL(LeadSource, "Referral"),
        ****NOT(ISBLANK(Referral_Source__c))
        )****
    ),
    OR(
        Amount > 1000,
        AND(
            ISPICKVAL(Type, "New Business"),
            Probability > 50
        )
    ),
    NOT(
        AND(
            ISNEW(),
        ****ISCHANGED(Status)
        )****
    ),
    NOT(ISBLANK(Email))
)

Regarding the additional validation rules, they seem to be correct and well-formed. You can add them to the existing validation rule by combining them with the AND function, like this:

AND(
    NOT(ISBLANK(Account.Name)),
    OR(
        AND(
            ISPICKVAL(LeadSource, "Web"),
            Lead_Source_Details__c <> ""
        ),
        AND(
            ISPICKVAL(LeadSource, "Referral"),
            NOT(ISBLANK(Referral_Source__c))
        )
    ),
    OR(
        Amount > 1000,
        AND(
            ISPICKVAL(Type, "New Business"),
            Probability > 50
        )
    ),
    NOT(
        AND(
            ISNEW(),
        ****ISCHANGED(Status)
        )****
    ),
    NOT(ISBLANK(Email)),
    NOT(ISBLANK(Contact__c)),
    NOT(ISBLANK(LeadSource))
)

This validation rule now includes all three additional criteria and will trigger an error if any of the specified fields are blank.

3
  • Properly formatting the formula here is vital to understanding the issue and presenting the solution.
    – Derek F
    Mar 18 at 13:55
  • AND(ISNEW(),ISCHANGED(Status)) will always be false, so the resulting NOT will always be true.
    – sfdcfox
    Mar 18 at 15:49
  • Thank you for the guidance @DerekF . Mar 21 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.