You are here:
Create a Simple Before-Save Record-Triggered Flow That Updates a Record
Learn how to build a before-save record-triggered flow that automatically updates an opportunity's name when it's created.
Required Editions
| View supported editions. |
| User Permissions Needed | |
|---|---|
| To open, edit, create, activate or deactivate a flow using all flow types, elements, and features available in Flow Builder, including Einstein and Agentforce for Flow: | Manage Flow |
Your company has a naming convention for opportunities, but sales reps forget to use it when they create opportunities. The inconsistent opportunity names make it hard for management to quickly scan the opportunities during audits. Create a before-save flow that updates the opportunity name automatically.
You want opportunity names to include the related account name, the amount, and the close
date. For example, an opportunity name for the Acme account is Acme - $10,000 -
5/15/2026.
This example uses a before-save flow, which means it runs when someone clicks Save, but before Salesforce saves the record to the database.
Create a Record-Triggered Flow
-
Open the Flows list view.
- From Setup, in the Quick Find box, enter Flows, and then select Flows.
- From the Automation app, select the Flows tab.
- From the Flows tab in any Lightning app, click the actions menu and select Open Flow.
-
Create a record-triggered flow.
- From the Automation Lightning app, click New. Select the Triggered Automations tile, and then select the Record-Triggered Flow tile.
- From Setup, click New Flow, select the Triggered Automations tile, and then select the Record-Triggered Flow tile.
The Configure Start panel opens.
Specify When Your Flow Runs
The Start element is where you tell your flow what to watch for. You want the flow to run when a user creates an opportunity, and only when the Amount field changes.
-
On the Configure Start panel, for Object, select
Opportunity.
This step tells the flow to watch opportunity records.
-
For Trigger the Flow When, select A record is
created.
Don't set any conditions because you want this flow to run on all new opportunities.
-
For Optimize the Flow for, select the Fast Field Updates
tile.
This step creates a before-save flow, which is perfect for updating fields on the triggering record.
The start element looks like this:
Update the Opportunity Name
Create a formula resource to configure the name according to the company requirements. Use an assignment element to update the triggering opportunity.
-
Create a formula resource to create the name.
-
To open the Toolbox, click the
.
- Click New Resource, and then select Formula.
- For API Name, enter CreateOpportunityName.
- For Description, enter Creates an opportunity name that includes the related account's name, the opportunity's amount, and the opportunity's close date. Adds dashes between the different parts of the name.
-
For Data Type, select Text.
Select Text because the formula returns a text value.
- For Formula, click Insert a resource.
-
Select Triggering Opportunity | Account ID | Account Name.
If there are multiple options for Account ID, select the one with the arrow next to it, which indicates going to the next menu level.
-
After the account name, enter & " - $" &TEXT and
then add parentheses around
{!$Record.Amount}.This step adds a dash after the account name, and $ before the opportunity amount. It also tells the flow to return the amount as text instead of currency, so it works with this text formula. - Click Insert a resource | Triggering Opportunity | Amount.
-
After the opportunity amount, enter & " - " &TEXT
and then add parentheses around
{!$Record.CloseDate}.This step adds a dash after the opportunity amount and tells the flow to return the close date as text instead of a date value. That way, it works with this text formula.
-
Click Insert a resource | Triggering Opportunity | Close Date.
The full formula looks like this:
{!$Record.Account.Name} & " | " &TEXT({!$Record.Amount}) & " | " &TEXT({!$Record.CloseDate}).
-
To open the Toolbox, click the
-
Add an assignment to set the name.
-
Click
, and select Assignment.
The Assignment panel opens. -
For Label, enter Set Opportunity Name.
The API name auto-fills.
- For Description, enter Sets the opportunity name to the name created by the CreateOpportunityName formula.
- In the Set Variable Values section, for Variable, select Triggering Opportunity and then select Name.
- For Operator, select Equals.
-
For Value, select the CreateOpportunityName formula
resource.
-
Click
Save the Flow
- Click Save.
-
For Flow Label, enter Update New Opportunity Name.
The Flow API name auto-fills.
- For Description, enter Updates the name of new opportunities to include the account name, opportunity amount, and opportunity close date.
- Click Save.
Test and Activate Your Flow
Test your flow to make sure that it sets the correct name when you create an opportunity.
- Create a test account and an opportunity to use for testing. Give the opportunity a sample name, such as test.
-
Run the flow debugger.
- Go back to your flow.
- Click Debug.
- For Opportunity, select your test opportunity.
- Click Run.
-
Review the debug log.
- If the debug run finished without errors, go to the next step.
- If the debug run had errors, fix the errors listed in the debug log.
-
Activate the flow.
- Click Activate.
The flow is now active and automatically runs whenever a user creates an opportunity. - Create another test opportunity to make sure the flow works after activation.
What's Next
You've built a before-save record-triggered flow that automatically updates an opportunity name to comply with your company naming policy.
You learned important new skills:
- Creating a before-save record-triggered flow.
- Using the Assignment element to assign values to a flow resource.
- Setting a field value on the new record with a reference to the triggering record.
- Creating a formula that builds an opportunity name from the triggering record and related record field values.

