Salesforce Flows - Use Not Contains, Not Starts With and Not Ends With Operators in Flow

In this post we will see how to use Not Contains (Does Not Contain) function or operator in Salesforce Flows. Also, we will see a Workaround to use Not Starts With and Not Ends With operators in Salesforce Flows. All these operators are not available directly in Flow Elements but we can use Custom Condition Logic in Flows to implement these. We will go through an efficient "Does not Contain" workaround by using Custom Condition Logic in Salesforce Flows.

FLOW CUSTOM CONDITION LOGIC

If you work on Flows in Salesforce, you might have come across scenarios where you need to put/use condition logics to filter data like : checking if a particular field contains some particular text or if value of field starts or ends with a particular text or number. These are useful and powerful operators while working on Flows in Salesforce and are available to apply in Flow Elements directly. 

But what if you wanted to check the opposite of it? Somebody messaged me directly to get answer to this so I thought maybe I will share this easy hack with you all.  

Not contains , Not Starts with or Not Ends with are not directly available as operators in Salesforce Flows yet. But we can use Custom Condition Logic in Flow as a Workaround to use them anyways. See below


How to use NOT CONTAINS in Salesforce Flow?

The simple step to use Does Not Contain in a Flow is by using using custom condition logic.
First we simply use Contains and then use NOT keyword in Condition Logic.

For Example : If I want to check if a particular text field say "Contact Mobile Phone" Contains symbol '+' ,  I will first put the operator as contains and then use Custom Logic and put Not Keyword before of it.

NOT CONTAINS IN SALESFORCE FLOWS
In the example above, it was a Record Triggered Flow on Contact.  I had to check for 2 conditions: 

1. Mobile Phone doesn't contain symbol "+" . 
AND
2. Mobile Phone field value is not null 

For Condition 1 : I used Contains operator for now (Note: Later we will use the condition logic and put NOT before condition 1 as shown in screenshot above). 

For Condition 2 : I simply used standard Null Check operator.

Things to Note :  NOT CONTAINS operator is not directly available. So, we need to use "Conditional Logic" instead of "All Conditions are Met (AND) ". 
NOT CONTAINS IN SALESFORCE FLOWS

Since we used Custom Condition Logic, now the simple trick is to put NOT operator before Condition 1 since we need NOT CONTAINS instead of CONTAINS.

So our final CONDITION LOGIC becomes  NOT (1) AND 2 which is better written as (NOT (1)) AND (2).

And it's done!


How to use NOT STARTS WITH in Salesforce Flow?

The concept for this remains same. To use Not Starts With in a Flow in Salesforce, use Starts With Operator in the condition and simply use Custom Condition logic and then put NOT in front of that condition.

NOT STARTS WITH IN SALESFORCE FLOW


How to use NOT ENDS WITH in Salesforce Flow?

The concept for this also remains same. To use Not Ends With in a Flow in Salesforce, use Ends With Operator in the condition and simply use Custom Condition logic and then put NOT in front of that condition.

NOT ENDS WITH IN A SALESFORCE FLOW

Hit the below Link to Subscribe 
Subscribe to Accidental Coder- A Salesforce Blog by Email

Checkout all Flow Related Posts on this Blog : Flow Posts : Use Cases and Scenarios

If you like reading my content, Do Subscribe to my YOUTUBE Channel to receive latest updates here: https://www.youtube.com/channel/UCdfi8Sq7iOcxnFhsgulWHeg/videos?view=0&sort=p&flow=grid

Learn Salesforce Development from Scratch

Get Sharing and Visibility Designer Certification

Learn Flows Online

 

Comments

  1. This was super helpful. I was searching for a way to apply a "DOES NOT CONTAIN" condition. Your example and explaination of custom condition logic was perfect. Thank you!

    ReplyDelete
  2. This does not work

    ReplyDelete
    Replies
    1. Hi. The first one can simply be 2 AND NOT 1

      Delete
  3. Amazing resource. Thank you!

    ReplyDelete
  4. Works perfectly. Thank you!

    ReplyDelete

Post a Comment

Thanks for your Feedback!

PLATFORM APP BUILDER CERTIFICATION - 78% OFF

POPULAR POSTS

Salesforce Flow Examples : Flow Use Cases and Scenarios

Flows | Use Flows to Bulk Update Records from List View in Salesforce

Flow Bulkification | Mass Update Records from Flows in Salesforce


Never Miss Latest Posts