Upskill on Flow – Learn How to Use DOESN’T CONTAINS Operator – and Show-Off!

Upskill on Flow – Learn How to Use DOESN’T CONTAINS Operator – and Show-Off!

Last Updated on March 17, 2022 by Rakesh Gupta

Big Idea or Enduring Question:

What if your use case requires you to use DOESN’T CONTAINS operator in Flow?

With a sigh, you may want to remind me that, in Salesforce Flow, one cannot use the DOESN’T CONTAINS operator to filter the records!

My response? – So, what! We are savvy Salesforce users, aren’t we? If so then, why not improvise?!!! Let us be creative and think out-of-the box – after all, we are Salesforce Ninja for nothing!

Salesforce Flow indeed is one of the most powerful tools provided by Salesforce to implement business requirements declaratively. If so then, let us build on that by creatively repurposing elements within Salesforce to do things that, at a first glance, may not seem doable!

In this article, I am going to share my tricks with you to show you how you can use DOESN’T CONTAINS operator in Flow. Let us start with a business use case.

The CONTAINS function compares 2 text strings and is widely used in Flow, Validation Rule, Process Builder, and Workflow Rules to search for a character or string in a text field.

For Example,

CONTAINS(NextStep,”Invoice”)

Returns TRUE if the word, “Invoice”, is found anywhere in NextStep.

Objectives:

This blog post will help us to understand the following

  • When should you use Before-Save vs After-Save Record-Triggered Flow?
  • Use a Decision element to filter out the result using the DOESN’T CONTAINS operator.
  • Use After-save Record-Triggered Flow to create a record.

Business Use Case

Brenda David is working as a System Administrator at Universal Containers (UC). She has received a requirement from the management to auto-create a Task when the ‘NextStep’ field – on the Opportunity object – is updated and it doesn’t contain words like Closed or Lost. 

  • Task Due Date = Opportunity Close Date

Automation Champion Approach (I-do):

There are multiple ways to solve the above business requirement. You can either use Apex trigger, Salesforce Flow, Process Builder, and more.

To solve this requirement, we will use the After-save Record-Triggered Flow. Check out this article to understand why we are using after-save record-triggered flow for this scenario. 

Before discussing the solution, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes going through the following Flow diagram and understand it. 

Let’s begin building this automation process.

Guided Practice (We-do):

There are 3 steps to solve Brenda’s business requirement using After-save Record-Triggered Flow. We must:

  1. Define Flow properties for Record-Triggered Flow.
  2. Add a decision element to check the NextStep field. 
  3. Add a create records element to create Task on Opportunity.

Step 1: Salesforce Flow – Define Flow Properties 

To reiterate – our requirement is to create a record on the (Task) object when the NextStep field on the Opportunity object is updated. In this case, we have to use the After-Save Flow on FeedItem because we are creating a record on the related object (Task) after the Opportunity Object is changed.

  1. Click Setup.
  2. In the Quick Find box, type Flows.
  3. Select Flows then click on the New Flow.
  4. Select the Record-Triggered Flow option and click on Next  and configure the flow as follows:
    1. How do you want to start building: Freeform
    2. Trigger the Flow When: A record is created or Updated 
    3. Run Flow: After the record is saved
    4. Object: Opportunity 
    5. Condition Requirements: None
  5. Click Done.

Step 2: Salesforce Flow – Using Decision Element – Check the NextStep Field 

Now add the Decision element to check whether the NextStep field contains words like ‘Closed’ or ‘Lost’. We will use custom logic to check ‘DOESN’T CONTAINS’. Use the following screenshot as a guide to step through the process:

  1. Under Toolbox, select Element
  2. Drag-and-drop Decision element onto the Flow designer. 
  3. Enter a name in the Label field; the API Name will auto-populate.
  4. Under Outcome Details, enter the Label the API Name will auto-populate.
  5. Condition Requirements to Execute OutcomeCustom Condition Logic Is Met
  6. Condition Logic1 AND NOT(2) AND NOT(3) 
    1. Row 1:
      1. Resource: {!$Record.NextStep}
      2. Operator: Is Changed  
      3. Value: {!$GlobalConstant.True}
    2. Click Add Condition 
    3. Row 2:
      1. Resource: {!$Record.NextStep}
      2. Operator: Contains 
      3. Value: Closed 
    4. Click Add Condition 
    5. Row 3:
      1. Resource: {!$Record.NextStep}
      2. Operator: Contains 
      3. Value: Lost
  7. Click Done.

Step 3: Salesforce Flow – Create Records – Add a task to on the Opportunity object 

The next step is to create a task on the Opportunity object. For this will use the Create Records element. 

  1. Under Toolbox, select Elements. Drag and drop Create Records onto the canvas. 
  2. Input the following information:
    1. Enter Label the API Name will auto-populate.
    2. How Many Records to Create: One
    3. How to Set the Record Fields: Use separate resources, and literal values
    4. Object: Task
    5. Set Field Values for the Entity Subscription 
      1. Row 1:
        1. Field: ActivityDate
        2. Value: {!$Record.CloseDate}
      2. Add Field
      3. Row 2
        1. Field: WhatId
        2. Value: {!$Record.Id}
      4. Add Field
      5. Row 3
        1. Field: OwnerId
        2. Value: {!$Record.OwnerId}
      6. Add Field
      7. Row 4
        1. Field: Status
        2. Value: Not Started 
      8. Add Field
      9. Row 5
        1. Field: Priority
        2. Value: Normal
  3. Click Done.

In the end, Brenda’s Flow will look like the following screenshot (I turned on Auto-Layout) for this flow: 

Once everything looks good, perform the steps below: 

  1. Click Save.
  2. Enter Flow Label the API Name will auto-populate.
  3. Click Show Advanced.
  4. How to Run the Flow: System Context Without Sharing-Access All Data 
  5. Type: Screen Flow
  6. API Version for Running the Flow: 52
  7. Interview Label: Doesn’t Contains Example {!$Flow.CurrentDateTime}
  8. Click Save

Almost there! Once everything looks good, click the Activate button.

Proof of Concept

Now onwards, whenever a user updates the NextStep field on the Opportunity object, and it doesn’t contain the word closed or Lost then, the Flow will auto-create a task for it! Voila!!  

Formative Assessment:

I want to hear from you!  

What did you learn from this post, is it relevant to you, and how will you modify the concepts taught in the post for your own business processes?  

Make a post and tag me on Twitter @automationchamp using #AutomationChampionFlow.

Author: - Rakesh Gupta
Technical Editor: - Munira Majmundar
Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!
Preferred Timing(required)

One thought on “Upskill on Flow – Learn How to Use DOESN’T CONTAINS Operator – and Show-Off!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Automation Champion

Subscribe now to keep reading and get access to the full archive.

Continue reading