Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I have trouble writing validation rules in Salesforce. So I have a checkbox field BypassWF__c which when checked bypasses workflow. I have three fields AssignedToUser__c, SupportUser1__c and SupportUser2__c. So if any of these 3 fields is updated (ISCHANGED), an email alert will be sent. I'm able to do for 1 field:

 AND(
 NOT($User.BypassWF__c),
 OR(ISCHANGED(AssignedToUser__c), ISNEW())
 )

How do I add if any 1 or both SupportUser1__c and SupportUser2__c are updated?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

The OR function takes as many logical expressions as you want, so you can simply do the following to check if any of the fields you mentioned have changed:

AND
(
    NOT($User.BypassWF__c),
    OR(ISCHANGED(AssignedToUser__c), ISCHANGED(SupportUser1__c), ISCHANGED(SupportUser2__c), ISNEW())
)

Further documentation for the OR function can be found here.

OR

Description

Determines if expressions are true or false. Returns TRUE if any expression is true. Returns FALSE if all expressions are false. Use this function as an alternative to the operator || (OR).

Use

OR(logical1, logical2...) and replace any number of logical references with the expressions you want evaluated.

share|improve this answer
    
Thanks @alex-tennant. Its working. I often get confused when I have AND and OR in a formula. Any suggestions? –  MnZ Jul 9 at 9:53
    
I often find that making sure you indent your formulas and reading them back to yourself in plain English helps, also thinking about what the inputs could be and working through the scenario. Sometimes reversing the order can help too, in this case the plain English version would be (you need to imagine the brackets): "If (AssignedToUser is changed OR SupportUser1 is changed... OR is a new record) AND Bypass__c is NOT TRUE (i.e. FALSE) then do something". –  Alex Tennant Jul 9 at 10:00
    
Just what I needed, the way to read through a big formula. Thank you very much. –  MnZ Jul 9 at 10:14
    
I like to use && for AND and || for OR. I find it makes my formulas a lot more readable. –  Daniel Hoechst Jul 9 at 14:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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