Loading

List Buttons to Create Related Records with Default Values

Publiseringsdato: Oct 13, 2026
Beskrivelse

Salesforce allows for a limited number of Flows (Process Builder was retired December 31, 2025). Because of this, it is important to use them sparingly and only when needed.

 

A common use case of the automation tools is to pull information from a related Account and use it as a default value when creating an Opportunity. Instead of using up an automation process, use a List Button instead by following the steps in this article.

Løsning

This article explains how to create a List Button in Salesforce that opens a new Opportunity from the Opportunities related list on an Account, with default values for Opportunity Name, Stage, Account ID and Close Date already filled in.

Example Scenario

In the example below, a custom button on the related Opportunity list within an Account record provides default values for the following fields when an Opportunity is created:

  • Opportunity Name
  • Stage
  • Account ID
  • Close Date

If you would like to create default values for different fields than the ones used in this example, add them to your formula.

Create a New Button

  1. Click the gear icon on the top-right corner, then click Setup.
  2. Click the Object Manager tab and select Opportunity.
  3. Click Buttons, Links, and Actions in the left navigation, then click New Button or Link.
  4. Provide a Label, for example New w/ Acct Info.
  5. Select List Button as the Display Type.
  6. Select Display in existing window with sidebar as the Behavior.
  7. Select URL as the Content Source.

Create the Formula

  1. Click in the formula text box on the bottom-left side of the screen.
  2. Select URLFOR from the Functions section on the right side of the screen.
  3. Highlight target, id, [inputs], [no override].
  4. Paste the following into the highlighted section:
    '/lightning/o/Opportunity/new?defaultFieldValues=Name=' +
  5. Select URLENCODE from the Functions section on the right side of the screen.
  6. Highlight text.
  7. Select Account from Select Field Type, then select Account Name from Insert Field.
  8. Paste the following into the section after (Account.Name):
    + " Opportunity" + ',AccountId=' + Account.Id + ',StageName=' + "Qualification" + ',CloseDate=' + TEXT(TODAY()+30))}
  9. Your entire formula should now look like this:
    {!URLFOR( '/lightning/o/Opportunity/new?defaultFieldValues=Name=' + URLENCODE(Account.Name)+ " Opportunity" + ',AccountId=' + Account.Id + ',StageName=' + "Qualification" + ',CloseDate=' + TEXT(TODAY()+30))}
  10. When the button is clicked, the formula creates a new Opportunity with these default values:
    • Name = (Name of the Account that you clicked this button from) Opportunity
    • Account = (the Account that you clicked this button from)
    • Stage = Qualification
    • Close Date = (30 days in the future from when you clicked this button)
  11. Click Check Syntax. You will see the message No syntax errors.
  12. Click Save.

Add the Button to the Page Layout

  1. Click the gear icon on the top-right corner, then select Setup.
  2. Click the Object Manager tab and select Account.
  3. Click Page Layouts in the left navigation and select the Page Layout that you are using.
  4. Scroll down to the Opportunities related list and click the wrench icon.
  5. Click the + to expand the Buttons section and uncheck the box for New.
  6. In the Custom Buttons section, move the New w/ Acct Info button to the Selected Buttons column.
  7. Click OK, then click Save.
Knowledge-artikkelnummer

000389967

 
Laster
Salesforce Help | Article