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))
    )
New contributor
KotaakAdmin321 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
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
    2 days ago

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.

2
  • Properly formatting the formula here is vital to understanding the issue and presenting the solution.
    – Derek F
    2 days ago
  • AND(ISNEW(),ISCHANGED(Status)) will always be false, so the resulting NOT will always be true.
    – sfdcfox
    2 days ago

Your Answer

KotaakAdmin321 is a new contributor. Be nice, and check out our Code of Conduct.

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.