You need to sign in to do that
Don't have an account?
Abhishek Singh 88
How to write code to validate custom logics like (1 OR 2) AND (3 OR 4)
Hi All,
I have a scenario where I have to assign owners based on various condition. Currently, we have Flows in place which checks the condition and does update Record. Now I am building an apex routing process where I need to check the conditions. In order to give flexibility, we want the condition should be configurable on UI and backend will do the calculation. e.g(1 OR 2) AND (3 OR 4) .
Any suggestion would be appreciated.
I have a scenario where I have to assign owners based on various condition. Currently, we have Flows in place which checks the condition and does update Record. Now I am building an apex routing process where I need to check the conditions. In order to give flexibility, we want the condition should be configurable on UI and backend will do the calculation. e.g(1 OR 2) AND (3 OR 4) .
Any suggestion would be appreciated.
When you create validation rules with multiple conditions you need to use these Operators
let assume we want Validates that the account Billing State/Province is a valid two-character abbreviation if Billing Country is CA or CAN.
so it writes like that
AND (
OR( BillingCountry = "CA", BillingCountry="CAN"),
OR( LEN(BillingState) < 2,
NOT(
CONTAINS("AB:BC:MB:NB:NL:NT:NS:NU:ON:PC:QC:SK:YT", BillingState)
)
)
)
Explain-:
AND() = Returns a TRUE response if all values are true; returns a FALSE response if one or more values are false. Use this function as an alternative to the operator && (AND).
ex-: IF(AND(Price<1,Quantity<1),"Small", null)
OR() = 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).
ex-: IF(OR(ISPICKVAL(Priority, "High"), ISPICKVAL(Status, "New")), ROUND(NOW()-CreatedDate, 0), null)
NOT() = Returns FALSE for TRUE and TRUE for FALSE.
ex- : IF(NOT(ISPICKVAL(Status, "Closed")), ROUND(NOW()-CreatedDate, 0), null
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
Thanks.