Loading
Salesforce now sends email only from verified domains. Read More
Automate Your Business Processes
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Create a Simple Before-Save Record-Triggered Flow That Updates a Record

          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

          1. 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.
          2. Create a record-triggered flow.
            1. From the Automation Lightning app, click New. Select the Triggered Automations tile, and then select the Record-Triggered Flow tile.
            2. 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.

          Set up when you want your flow to run.
          1. On the Configure Start panel, for Object, select Opportunity.
            This step tells the flow to watch opportunity records.
          2. 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.
          3. 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:

          Start element with Fast Field Updates selected

          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.

          1. Create a formula resource to create the name.
            1. To open the Toolbox, click the Toolbox icon..
            2. Click New Resource, and then select Formula.
            3. For API Name, enter CreateOpportunityName.
            4. 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.
            5. For Data Type, select Text.
              Select Text because the formula returns a text value.
            6. For Formula, click Insert a resource.
            7. 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.
            8. 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.
            9. Click Insert a resource | Triggering Opportunity | Amount.
            10. 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.

            11. Click Insert a resource | Triggering Opportunity | Close Date.
              The full formula looks like this: {!$Record.Account.Name} & " | " &TEXT({!$Record.Amount}) & " | " &TEXT({!$Record.CloseDate}).
            Formula resource that calculates the name
          2. Add an assignment to set the name.
            1. Click Add element plus icon, and select Assignment.
              The Assignment panel opens.
            2. For Label, enter Set Opportunity Name.
              The API name auto-fills.
            3. For Description, enter Sets the opportunity name to the name created by the CreateOpportunityName formula.
            4. In the Set Variable Values section, for Variable, select Triggering Opportunity and then select Name.
            5. For Operator, select Equals.
            6. For Value, select the CreateOpportunityName formula resource.
              The configured assignment element

          Save the Flow

          Save the record-triggered flow.
          1. Click Save.
          2. For Flow Label, enter Update New Opportunity Name.
            The Flow API name auto-fills.
          3. For Description, enter Updates the name of new opportunities to include the account name, opportunity amount, and opportunity close date.
          4. Click Save.

          Test and Activate Your Flow

          Test your flow to make sure that it sets the correct name when you create an opportunity.

          1. Create a test account and an opportunity to use for testing. Give the opportunity a sample name, such as test.
          2. Run the flow debugger.
            1. Go back to your flow.
            2. Click Debug.
            3. For Opportunity, select your test opportunity.
            4. Click Run.
          3. 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.
          4. Activate the flow.
            1. Click Activate.
            The flow is now active and automatically runs whenever a user creates an opportunity.
          5. 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.
           
          Loading
          Salesforce Help | Article