Skip to main content
TrailblazerDX, the ultimate AI learning event is heading back to San Francisco March 6-7, 2024. Register Now and save 35% with code T24DEYE424.

Build an Autolaunched Flow

Learning Objectives

After completing this unit, you’ll be able to:

  • Create a flow that runs from a custom button.
  • Create a custom button that runs an autolaunched flow.
Note

This badge is one stop along the way to Flow Builder proficiency. From start to finish, the Build Flows with Flow Builder trail guides you through learning all about Flow Builder. Follow this recommended sequence of badges to build strong process automation skills and become a Flow Builder expert.

Automation That Runs with a Single Click

A support tech helping a customer on a call.

Salesforce admin and business analyst Flo Smith has been working with the Pyroclastic, Inc. support managers to automate business processes. In this module, you’re a Salesforce admin on Flo’s team, helping her automate some of Pyroclastic’s business processes. Flo recently learned that when a customer calls with an issue that they’ve received support for in the past, support technicians want the ability to clone the related closed case. The standard Clone button copies too much information that they don’t need. They want only specific details, and they want the newly cloned record to have a link back to the original record. 

Salesforce is pretty powerful, and Einstein is pretty smart, but only a call agent can determine when the called-in problem really is the same as something that was handled before.

Flo considers these business requirements. Cloning specific information from a closed case requires no user interaction. Deciding when to perform this selective cloning process does require the user’s judgment. That’s a great candidate for an Autolaunched flow. Flo asks you to build this new flow and a custom button to initiate it.

Ready to Get Hands-on with Flow Builder?

Launch your Trailhead Playground now to follow along and try out the steps in this module. To open your Trailhead Playground, scroll down to the hands-on challenge and click Launch. You also use the playground when it's time to complete the hands-on challenges.

Here are the high-level steps you follow in the scenario.

  1. Create an Autolaunched flow with input variables.
  2. Get the URL for the flow.
  3. Create a custom button to run the flow and pass values into the flow’s variables.

Create an Autolaunched Flow with Input Variables

Before you start, you ask the support teams exactly what information they want in the cloned record. They decide that the most important fields from the closed case are:

  • ID
  • Subject
  • Account ID
  • Type

Note that the newly cloned case will have its own ID. You need a separate, custom field to capture the cloned case in the new case record.

Because you’re building an Autolaunched flow, not a record-triggered flow, when the flow runs, it doesn’t know which record it ran from unless you provide that information. You might remember a setting you used with a variable in the Flow Builder Logic badge: Available for input. In that badge, a child flow needed values from its parent flow, so you passed record data to the flow’s input variables. You do the same thing here to provide information to an Autolaunched flow.

  1. Create a custom field on the Case object:
    1. Data Type: Lookup Relationship
    2. Related To: Case
    3. Field Label: Cloned From
    4. Field Name: Cloned_From
    5. Leave other settings, field-level security, and page layouts as default.
  2. Create an Autolaunched Flow.
  3. Create an input variable for the case ID:
    1. API Name: caseId
    2. Data Type: Text
    3. Available for input: checked
  4. In the same way, create three more text variables available for input:
    1. caseSubject
    2. caseAccountId
    3. caseType

      The resources sidebar, with the caseAccountId, caseId, caseSubject, and caseType variables.
  5. Add a Create Records element that clones the case:
    1. Label: Clone Case
    2. API Name: Clone_Case
    3. How to Set the Record Fields: Use separate resources, and literal values
    4. Object: Case
    5. Set Field Values for the Case:
      • AccountId, caseAccountId
      • Subject, caseSubject
      • Type, caseType
      • Cloned_From__c, caseId

        The New Create Record window corresponding to the preceding instructions.
  6. Save the flow.
    For Flow Label, enter Clone Closed Case.

    The Activate button in the Flow Builder button bar.
  7. (Optional) Click Activate to activate the flow.
    As you learned in Flow Builder Logic, unless the flow is activated, only users with the Manage Flows permission can run it. Most admins have the Manage Flows permission, but most users who run the flows don’t have that permission.

Get the URL for the Flow

Now that the flow is built, you need a custom button to run it. Like custom links, custom buttons are directly related to a specific object. You can place them on any page layout or Lightning page related to that object. Custom buttons and links can run any URL. They can even merge record fields into a URL by including URL parameters, which you learn about in the next unit.

Note

To learn more about custom buttons and links, check out the Create Custom Buttons and Links unit in the Lightning Experience Customization badge.

Because custom buttons run URLs, you need to know the URL of your Autolaunched flow before you can create the button. Here’s how to find it.

  1. In the All Flows list view, find the Clone Closed Case flow and click Show more actions, then View Details and Versions.

    The Flows page in Setup, highlighting a flow’s Show more actions menu.
  2. Copy and paste the URL somewhere handy.

    A flow’s Details and Versions page, highlighting the URL field. In this image, the flow’s API name is Assign_Case_Priority, so the URL is /flow/Assign_Case_Priority.
Note

Don’t worry that the flow’s URL doesn’t look like a complete URL because it doesn’t have an https or the salesforce.com domain anywhere in it. The URL shown here is a relative URL. When a URL doesn’t have a domain name, all web browsers assume they should just go to that address on the current server. For example, given this URL, /flow/AutomotiveServiceFlow, on the trailhead.salesforce.com website, the browser assumes that the URL points to another page on the same site and fills in the rest of the URL: https://trailhead.salesforce.com/flow/AutomotiveServiceFlow.

Create a Custom Button to Run the Flow

With the flow’s URL in hand, it’s time to create the button itself.

  1. In the Object Manageropen the Case object.
  2. Click Buttons, Links, and Actions.
  3. Click New Button or Link.

    The New Button or Link window.
  4. For Label, enter Clone Closed Case.
  5. For Display Type, select Detail Page Button.
    This setting tells Salesforce that this is a button, not a link, and that it goes with the rest of the record buttons near the top of the page.
  6. For Behavior, select Display in existing window without sidebar or header.
    This setting makes the flow run in the current browser tab, instead of opening a new tab.
  7. In the URL editor (the big unlabeled text area below Select Field Type), enter the URL of the Clone Closed Case flow.
  8. Click Quick Save.

But we’re not done yet! The button knows which flow to run, but the flow still doesn’t know which record the button is on. In the next unit, you learn how to pass record information from the button to the flow.

Resources

Keep learning for
free!
Sign up for an account to continue.
What’s in it for you?
  • Get personalized recommendations for your career goals
  • Practice your skills with hands-on challenges and quizzes
  • Track and share your progress with employers
  • Connect to mentorship and career opportunities