Back to LinkedIn posts

LinkedIn post 230

πŸš€ Workflow Rules vs. Flows: The CONTAINS dilemma

πŸš€ Workflow Rules vs. Flows: The CONTAINS dilemma

Salesforce veterans might recall how simple life seemed with Workflow Rules when handling comparisons using CONTAINS.

You could just slap in multiple values and call it a day:
β€’ Email CONTAINS "@SpamSender.com,@spammy.net,@spammer.org"

However, the shift to Record-Triggered Flows introduces a wrinkle: this doesn’t work anymore.

Per the Salesforce documentation:
β€œPassing multiple comma-separated values against the CONTAINS operator in the same condition doesn’t evaluate the Process or Flow as intended.” πŸ™ƒ

The Result?

Your old but elegant one-liner now turns into:
β€’ Email CONTAINS "@SpamSender.com"
β€’ OR Email CONTAINS "@spammy.net"
β€’ OR Email CONTAINS "@spammer.org"

What if you have to deal with a huge list? 🀯

One solution is to invert the comparison πŸ”„

πŸ‘‰ Instead of checking if Email contains a spammy domain, extract the domain from the email and flip the logic:

Extract the email domain:
β€’ MID( Email, FIND( "@", Email ), 255 )

Compare it against your list of spam domains:
β€’ SpamDomainList CONTAINS EmailDomain

This approach will work better when dealing with dynamic lists too (say, lists stored in custom metadata or custom objects).

πŸ’£ CAVEATS - You have to ensure:
πŸ‘‰ the Email field is non-empty and properly formatted
πŸ‘‰ the domains match are case-sensitive
πŸ‘‰ avoid false positives (improbable but still a concern) by prepending and appending separators (commas) to the email domain and the spam domain list when doing the "contains" comparison