0

Basically I need a validation rule to say

IF field “HasOptedOutOfEmail” is unchecked, and mailing country = Canada, then field Canada_Email_Consent__c needs to be Updated. However the record shouldnt be saved if the picklsit value for Canada_Email_Consent__c = No-Consent, the record should only be saved if picklist contains the word "Yes"

IF field “HasOptedOutOfEmail” is unchecked, and mailing country <> Canada, then field Canada_Email_Consent__c doesn’t need to be completed, and the record can be saved

Field name: HasOptedOutOfEmail Datatype : Checkbox

Field name: Canada_Email_Consent__c Datatype : Picklist

Hoping you guys can help

4 Answers 4

1

Try this:

If (
    And (
        HasOptedOutOfEmail = false,
        MailingCountry = 'Canada',
        IsPickVal(Canada_Email_Consent__c, '')
    ),
    true,
    false
)
2
  • Canada_Email_Consent__c is a picklist value , so i am getting an error on your validation
    – user8746
    Jun 24, 2014 at 15:33
  • I've updated my answer to use IsPickVal Jun 24, 2014 at 15:52
1

Try:

IF(
    AND(HasOptedOutOfEmail = false, Mailing_Country__c = 'Canada'),
    IF(
        ISPICKVAL(Canada_Email_Consent__c, 'No-Consent'),
        true,
        ISBLANK(TEXT(Canada_Email_Consent__c))
    ),
    false
)

This basically says:

If HasOptedOutOfEmail is unchecked and Mailing_Country__c is Canada, then check Canada_Email_Consent__c. If Canada_Email_Consent__c is 'No-Consent', then return true. Otherwise, check if Canada_Email_Consent__c is blank. When checking if Canada_Email_Consent__c is blank, it converts it to text first (which is required for a picklist) and then evaulates if it is blank. If it is blank, it returns true, otherwise it returns false.

Check out IF(), AND(), ISPICKVAL(), ISBLANK(), and TEXT() for more details.

6
  • @ Jess Altman, Canada_Email_Consent__c is a picklist value , so i am getting an error on your validation
    – user8746
    Jun 24, 2014 at 15:32
  • Alright. Let me update my answer. I didn't realize it was a picklist. Jun 24, 2014 at 15:34
  • ( i applogise i thought i put it in my criteria , however i put put data type: data doh ! ) in the validation is it possible to say if HasOptedOutOfEmail unchecked then Canada_Email_Consent__c cant be picklist value "No-Consent"
    – user8746
    Jun 24, 2014 at 15:37
  • That is a bit different from what you originally asked @user8746. Can you update your original question to be as specific as possible? What you are looking to do seems to be changing as we go. Jun 24, 2014 at 15:40
  • i have updated with all relevant changes
    – user8746
    Jun 24, 2014 at 15:44
0

Try this:

AND(NOT(HasOptedOutOfEmail), Mailing Country = Canada, NOT(ISPICKVAL(Canada_Email_Consent__c, "Yes")))

0

After Several attempts, the formula is

AND( ISCHANGED(HasOptedOutOfEmail), HasOptedOutOfEmail = false, MailingCountry = 'Canada', ISPICKVAL(Canada_Email_Consent__c, 'No-Consent') )

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.