Last Updated on June 7, 2022 by Rakesh Gupta
Salesforce Flow is one of the most powerful tools provided by Salesforce to implement business requirements declaratively. Till date, I have written 200+ flows just for my blog posts!
Salesforce Flow helps businesses to save time, as well as money, by implementing solutions quickly. Implementation of Salesforce Flow is straightforward – you create a Flow; tests it; and then, use Change Set to deploy it to Production. The best part is, you do not have to write test classes for your Flows.
But there are few limitations of Salesforce Flow vis-a-vis Workflow! Yup! You read that right! Workflow has an upper hand when defining Rule Criteria!
Let me unravel this mystery by offering an example: As a System Administrator, you receive a requirement to auto-create a Quote record whenever Opportunity Stage is Proposal/Price Quote or Negotiation/Review.
To achieve the above business requirement, through a Workflow Rule, you may do something similar to as shown in the following screenshot:
But to achieve the same requirement through Record-Triggered Flow, you may do something similar to as shown in the following screenshot:
If you created Record-triggered Flow using Salesforce Flow before then, you know how I set two values for Stage picklist. But, for those, who are relatively new to Salesforce Flow, let me walk you through the flow step-by-step. Workflow Rule allows you to select multiple values for a picklist. If you look at the Workflow Rule screenshot, I have chosen (defined) both the picklist value in a single line using commas (,).
But if you try to achieve the same thing using the Record-triggered Flow, it will not work. Unlike Workflow rules, one cannot develop a rule criteria to select multiple picklist values, in a single stroke, using Record-triggered Flow! For the detailed explanation, please refer to the following article published by Salesforce – CONTAINS with multiple comma separated values does not trigger a Flow.
The solution suggested by Salesforce (is the same as I have used in Process Builder screenshot) is good for the simple business use case. But what about a complicated requirement where you need to take other things into consideration (like Amount > $1000 and Close Date > Today) while defining flow entry criteria?
Ugh!! what a nightmare – Prone to errors and a whopping headache!
For, in the aforementioned scenarios, you will be using multiple AND/OR statement, as I did in the preceding screenshot – (1 OR 2) AND 3 AND 4.
Thanks to highly talented users of automationchampion.com blog for their constructive feedbacks and, especially, for challenging me to come up with a streamlined solution for the aforementioned problem. Well, challenge accepted!
In this article, I am going to share my tricks to solve the above business use case using a simple formula. Let us start with a business use case.
Business Use Case
Edward Backhouse is working as System administrator at GurukulOnCloud. At GurukulOnCloud they are using Record-triggered flow to streamline Sales Processes. Today, Edward received a requirement to auto-create a Quote record – as soon as an Opportunity meets the following conditions:
- Stage = Proposal/Price Quote or Negotiation/Review
- Amount > 1,000
- Close Date > Today
Automation Champion Approach (I-do):
There are a few possible solutions for the above business scenario, but I’ll use After-save Record-Triggered Flow to solve the business requirement. Let us spend some time to understand the Case formula in Salesforce and how to use it.
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 understanding it.
Let’s begin building this automation process.
Guided Practice (We-do):
There are 4 steps to solve Edward’s business requirement using Record-triggered Flow. We must:
- Define flow properties for record-triggered flow
- Create a formula to determine if the stage is matching
- Add a decision element to check stage, amount, and close date criteria
- Add a create records element to create a quote
Step 1: Define Flow Properties
- Click Setup.
- In the Quick Find box, type Flows.
- Select Flows then click on the New Flow.
- Select the Record-Triggered Flow option, click on Create
- Object: Opportunity
- Trigger Opportunity Flow When: A record is created or updated
- Set Entry Criteria
- Condition Requirements: None
- Optimize the Flow For Action and Related Records
- Click Done.
Step 2: Formula to Determine if the StageName is Matching
- Under Toolbox, select Manager, then click New Resource to determine whether the record is created or updated.
- Input the following information:
- ResourceType: Formula
- API Name: forT_StageName
- Data Type: Text
- Formula:
- CASE({!$Record.StageName} ,
“Proposal/Price Quote”, “True”,
“Negotiation/Review”, “True”,
“False”
)
- CASE({!$Record.StageName} ,
- Click Done.
Step 3: Using Decision Element to Check Stage, Amount, and Close Date Criteria
Now we will use the Decision element to check if stagename, close date, and amount as described in the requirement.
- On Flow Designer, click on the +icon and select the Decision element.
- Drag-and-drop Decision element onto the Flow designer.
- Enter a name in the Label field; the API Name will auto-populate.
- Under Outcome Details, enter the Label theAPI Name will auto-populate.
- Condition Requirements to Execute Outcome: All Conditions Are Met (AND)
- Row 1:
- Resource: {!forT_StageName}
- Operator: Equals
- Value: True
- Click Add Condition
- Row 2:
- Resource: {!$Record.Amount}
- Operator: Greater Than
- Value: 1000
- Click Add Condition
- Row 3:
- Resource: {!$Record.CloseDate}
- Operator: Greater Than
- Value: {!$Flow.CurrentDate}
- Row 1:
- Click Done.
Step 4: Add Create Records Element to Create a Quote
The final step is to create a quotation record. For this, we will use Create Records element.
- On Flow Designer, below the Yes node, click on the +icon and select the Create Records element.
- Enter a name in the Label field; the API Name will auto-populate.
- Input the following information:
- How Many Records to Create: One
- How to Set the Record Fields: Use separate resources, and literal values
- Object: Quote
- Set Field Values for the Quote
- Row 1:
- Field: Status
- Value: Draft
- Click Add Field
- Row 2:
- Field: OpportunityId
- Value: {!$Record.Id}
- Click Add Field
- Row 3:
- Field: Name
- Value:{!$Record.Name}
- Click Done.
In the end, Edward’s Flow will look like the following screenshot:
Once everything looks good, perform the steps below:
- Click Save.
- Enter Flow Label the API Name will auto-populate.
- Click Show Advanced.
- API Version for Running the Flow: 55
- Interview Label: Use Formula in Flow {!$Flow.CurrentDateTime}
- Click Save.
Almost there! Once everything looks good, click the Activate button.
Proof of Concept
Next time, when Opportunity records are created, or updated, by the user, the flow we created (Using Record-Triggered Flow) will fire and check the criteria. If it meets the stated criteria then, the record-triggered flow will create a Quote record, as shown in the following video:
I hope you can learnt from the blog about how to select multiple picklist values using Salesforce Flow!! Yes, go ahead! Show off your newly acquired skills to your friends, colleagues and families!
Jokes apart, mastering these skills will enhance your productivity and propel you to try various permutations and combinations to incorporate automation in your day-to-day processes and procedures.
Formative Assessment:
I want to hear from you!
What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? Feel free to share in the comments below.