Flow Formula to Standardize Opportunity Name

Flow Formula to Standardize Opportunity Name

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:

  1. Update fields on new or changed records
  2. 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:

  1. Define Flow properties for record-triggered flow
  2. Create a formula to construct the opportunity name
  3. Add an Assignment element to the opportunity name

Step 1: Define Flow Properties

  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, click on Create and configure the flow as follows:
    1. Object: Opportunity
    2. Trigger the Flow When: A record is created or updated
    3. Set Entry Criteria
      1. Condition Requirements: None
    4. Optimize the Flow For Fast Field Updates
  5. Click Done.

Step 2: Formula to Construct the Opportunity Name

  1. Under Toolbox, select Manager, then click New Resource to construct the opportunity name using concatenate formula. 
  2. Input the following information:
    1. Resource Type: Formula
    2. API Name: forT_OpportunityName
    3. Data Type: Text
    4. Formula: {!$Record.Account.Name}&’ | ‘&TEXT({!$Record.Type})&’ | ‘&TEXT({!$Record.Amount})&’ ‘&TEXT({!$Record.CurrencyIsoCode})&’ | ‘&TEXT({!$Record.StageName})
  3. 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. 

  1. On Flow Designer, click on the +icon and select the Assignment element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. Set Variable Value
    1. Row 1:
      1. Field: {!$Record.Name}
      2. Operator: Equals
      3. Value: {!forT_OpportunityName}
  4. Click Done.

In the end, Olivia’s Flow will look like the following screenshot:

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. API Version for Running the Flow: 54
  5. Interview Label: Standardize Opportunity Name {!$Flow.CurrentDateTime}
  6. 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.

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

2 thoughts on “Flow Formula to Standardize Opportunity Name

  1. I am getting a syntax error trying the formula in flow-

    {!$Record.Account.Name}&’ | ‘&TEXT({!$Record.Type})&’ | ‘&TEXT({!$Record.Amount})& ’ | ‘&TEXT({!$Record.StageName})

Leave a Reply

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