Last Updated on April 16, 2022 by Rakesh Gupta
Big Idea or Enduring Question:
- How do you standardize the opportunity name to follow business defined naming convention?
Objectives:
After reading this blog, you’ll be able to:
- Understand when to use before-save flow
- Use the formula to concatenate fields in the flow
- Use assignment element to update the records
- and much more
Business Use case
Olivia Rodrigo is working as a System Administrator at Gurukul on Cloud (GoC). GoC wants all of their opportunities to follow the same naming convention, but users often forget or put the wrong name. Olivia has received a requirement from her sales director to help the team standardize the opportunity name as below whenever the record is created or updated.
- Name:- Account Name | Type | Amount | Stage
Automation Champion Approach (I-do):
There are a few possible solutions for the above business scenario. However, our purpose, in this blog, is to learn about Flow and its features. Therefore, we will use Before-Save Record-triggered Flow to solve the above business requirement.
Using before-save allows us to accomplish the same goal as Process Builder (After-save Flow) – but much faster because each record does not get saved to the database again. Avoiding that extra save procedure means skipping another round of Assignment rules, Auto-response rules, and other customizations that take time to execute.
Use a Before-save Flow on the following use cases:
- Update fields on new or changed records
- Trigger a Validation rule (this is a custom solution not available out of the box)
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 Olivia’s business requirement using Before-Save Record-Triggered Flow. We must:
- Define Flow properties for record-triggered flow
- Create a formula to construct the opportunity name
- Add an Assignment element to the opportunity name
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 and configure the flow as follows:
- Object: Opportunity
- Trigger the Flow When: A record is created or updated
- Set Entry Criteria
- Condition Requirements: None
- Optimize the Flow For Fast Field Updates
- Click Done.
Step 2: Formula to Construct the Opportunity Name
- Under Toolbox, select Manager, then click New Resource to construct the opportunity name using concatenate formula.
- Input the following information:
- Resource Type: Formula
- API Name: forT_OpportunityName
- Data Type: Text
- Formula: {!$Record.Account.Name}&’ | ‘&TEXT({!$Record.Type})&’ | ‘&TEXT({!$Record.Amount})&’ ‘&TEXT({!$Record.CurrencyIsoCode})&’ | ‘&TEXT({!$Record.StageName})
- Click Done.
👉 Remove CurrencyIsoCode from the above formula if multi-currency is not enabled in your org.
TEXT() formula converts a Percent, Number, Date, Date/Time, picklist, or Currency field into Text. TEXT() returns output without any formatting, commas, or currency signs.
Step 3. Using Assignment Element to Update the Opportunity Name
The next step is to update the opportunity Name. We will use the Assignment element, as we are using before-save flow.
- On Flow Designer, click on the +icon and select the Assignment element.
- Enter a name in the Label field; the API Name will auto-populate.
- Set Variable Value
- Row 1:
- Field: {!$Record.Name}
- Operator: Equals
- Value: {!forT_OpportunityName}
- Field: {!$Record.Name}
- Row 1:
- Click Done.
In the end, Olivia’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: 54
- Interview Label: Standardize Opportunity Name {!$Flow.CurrentDateTime}
- Click Save.
Almost there! Once everything looks good, click the Activate button.
Proof of Concept
Now onwards, if a user creates or updates an opportunity, then the Before-save record-triggered flow will automatically update the opportunity name.
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.
I just wanted to display the name of the contact and its stage on the opportunity name This is the formula i used {!$Record.Name}&’ | ‘&TEXT({!$Record.StageName})
the syntax is correct, the flow is also working, the issue i am having is when i change the stage, its not replacing the stage name, it keep on adding the stage name to the opp name
Eg: Sam Thomas | Payment Recieved | Payment Verified | Payment Verified
Please share the screenshot of the element (Assignment or Record updates) where you update (map) the Name. Thank you!
Thank you for putting this together. This is working great when I edit and save the opportunity. How do I have this run when I am creating a new opportunity?
Either change the entry criteria and execute the flow on create (1); otherwise, add a decision element to ensure that flow fires on record creation by using record.id Is Null True (2).
I am getting a syntax error trying the formula in flow-
{!$Record.Account.Name}&’ | ‘&TEXT({!$Record.Type})&’ | ‘&TEXT({!$Record.Amount})& ’ | ‘&TEXT({!$Record.StageName})
It is copy paste issue. Replace ‘ with ‘