Auto Launched Flow in Salesforce

The auto launched flow is a sub flow that can called from other flows, DML operations, if any platform event occurs, and process builders.

In this Salesforce tutorial, we will learn about auto launched flow in Salesforce. In that, we will discuss the following points:

  • What is auto launched flow in Salesforce?
  • Example 1- create auto launched flow in Salesforce.
  • Example 2- create auto launched flow in Salesforce.

What is Auto Launched Flow in Salesforce

In Salesforce, the auto launched flow cannot run itself; it needs to be called by another tool, such as flow, apex, process builder, REST API, and more. This auto launched flow runs in the background.

The auto launched flow does not require any user interaction. It acts like a sub flow to other flows.

Uses of Auto Launched Flow in Salesforce

  • Suppose we have a task to create multiple flows and need the functionality that needs to be performed by all the flows; then, we can use an auto launched flow as a sub flow that comprises the functionality required by all flows.
  • The auto launched flow will run in the background. We can’t use any UI element on this one; it will just execute the logic.
  • The auto launched flow saves time, and we don’t need to create the same functionality repeatedly. It also helps us build a very simplified flow.

Example 1- Create Auto Launched Flow in Salesforce.

For example, we have a screen flow and a record trigger flow. Now, the requirement is that we need to send an email from both flows.

  • One option is to send an email from both flows individually by creating an Email Action on both flows.
  • The second option is instead of creating an email action on both flows, we can use the auto launched flow as a sub flow. On this flow, we will create an email action, and then we will call it from other flow whenever we need.

Prerequisites:

  • We need a screen flow where we can create a record and then email the user to confirm the account’s creation.
  • But we don’t create email action on the screen flow. We will call sub-flow, which is the auto-launched flow for sending an email.

We will create the auto-launched flow in Salesforce using the above scenario and the following steps.

Edit Screen Flow in Salesforce

1. We need to send an email when the account is created. For this, we need two things: the Recipient’s Email address and the Email Body.

  • The Recipient’s email we will be getting in the account record, but we need to create an Email Body.
  • We need a screen flow to create the email body. I have already created a Screen Flow for creating an account.
  • So, I will edit the screen flow and click on the Manager tab, where we can get the New Resource option. Click on the new resource option to create an Email Template.
Auto Launched Flow in Salesforce

2. Now, you have to create an email body. For that, in the Resource Type field, you have to select the Text Template option. Then, this API Name will be used in the sub flow.

  • Then, in the Body, we can enter the message that we want to share in the email.
  • After that, click the Done button to Save your email template resource.
Create Auto Launched Flow in Salesforce Lightning

Create Auto Launched Flow in Salesforce

3. Now, using the following steps, we will create an Auto Launched flow.

  • Log in to Salesforce Org. -> Click on the Setup. -> Home Tab. -> In Quick Find Box, Search for Flows. You will see an option under Process Automation. -> Click on Flows.
Auto Launched Flow in Salesforce Lightning

4. Click on the New Flow button to create a new flow.

Auto Launched Flow in Salesforce

5. As per the above scenario, we want to create an email action, which we will use in a different flow. For that, we will select the Autolaunched Flow option, and this flow will be used as a sub flow.

Then click on the Create button to proceed.

Auto Launched Flow in Salesforce Classic

6. Now, in this flow, we need to create two variables to take the value from the other flow. In our case, we will take value from screen flow. So, we will be creating the following two resources:

  • Email:
  • Email Body:

Click on the Manager tab. Click on the New Resource option. In the Resource Type field, select the Variable option. Then, enter the API Name as per your requirement.

  • The Email is in text format, select Data Type as Text. The Availability Outside The Flow must be checked for Input. If you do not check it, it will not be available for input in the screen flow whenever you choose it.
  • Then click on the Done button.

Create the same variable for the Email Body; the only change is that you have to change the API name, and the rest are the same.

Create a Auto Launched Flow in Salesforce

7. Now, we will add an Email Action to the auto launched flow. To do that, click on the Add Element icon. Then select the Action option under the Interaction category.

How to Create a Auto Launched Flow in Salesforce

8. Then, under the Category, we need to select the Email option, select the Send Email option, and enter the necessary information.

How to Create Auto Launched Flow in Salesforce Classic

9. We also need to set input values for the selected actions. For the Body here, we already have created the EmailBody variable. Select that variable. Then, we created an Email variable for the Recipient Address List and selected it.

  • Then click on the Done button.
What is Auto Launched Flow in Salesforce

10. As you click on the Save button then, you need to enter the following information.

  • Flow Label: Here, I have entered Auto-Launched flow for sending email.
  • Flow API Name: It will automatically populate as we click the text box.

Then click on the Save button.

Create Auto Launched Flow in Salesforce Classic

Again Edit Screen Flow

11. Now, we will add the Sub Flow to the Screen Flow. To do so, click the Add Element icon and select the Subflow under the Interaction option.

What is Auto Launched Flow in Salesforce Lightning

12. In the Referenced Flow option, select the Auto-Launched flow you created in the above steps. Then, enter the necessary information. The description is an optional field. You can leave it blank.

What is Auto Launched Flow in Salesforce Classic

13. Then, in the Set Input Values Fields, we will select the email and email template we created first in the screen flow, which will refer to the variable created in the auto-launched flow.

Then click on the Done button.

What is Auto Launched Flow in Salesforce example

14. Here, you can see that we have added the Subflow after the Create Account Records element because we want to execute this Subflow only after account creation.

  • This screen flow will be called the subflow, which is the Auto Launched flow. Then click on the Save button. After that, click on the Activate button.
How to Create a Auto Launched Flow in Salesforce example

Proof of Concept

15. Now, we will create the record with the screen flow and will check whether, after creating the record, it is sending an email or not.

Auto Launched flow in Salesforce Lightning example

16. Here, you can see I have got an email after creating the account.

Auto Launched flow in Salesforce example

This is how we can create the auto-launched flow and use it as a sub-flow in another flow in Salesforce.

Example 2- Create Auto Launched Flow in Salesforce

For example, we will create a record trigger flow so that when an account record is created, a contact record related to that account should also be created.

  • Then, the record-triggered flow will be called auto launched flow to create an opportunity related to that account.

We will create the auto launched flow in Salesforce using the above example and the following steps.

Create Record Trigger Flow in Salesforce

In the following steps, we will create a record trigger flow to automatically create contact records when a new account is created.

1. Click on the Setup. -> Home Tab. -> Search for Flows. -> Click on Flows. -> Click on the New Flow button. -> Then select Start from scratch and click on the Next button.

2. Select the Record Triggered Flow and click the Create button.

3. Then, in the Start, select In the Object field, select the triggering object. In our scenario, we need to create a flow on the Account.

  • In the Configure Trigger option, choose when we want to trigger this flow. Here, our flow should trigger when A Record is Created.

4. In the Create Records element, select which object’s record you want to create, but that object has a relationship with the parent object.

  • Here, we will select Contact Object and then map the contact fields with the account object.

Then, Save the Flow.

auto launched flow salesforce

You can read the whole article on Record Triggered Flow in Salesforce.

Create Auto Launched Flow in Salesforce

Now, we will create an auto launched flow for creating the opportunity records, which we will use as a sub flow in the record triggered flow.

Using the following steps, you can create an auto launched flow in Salesforce.

1. Click on the New Flow button. -> Then select Start from scratch and click on the Next button. -> Select the auto launched flow and click the Create button

  • First, in this flow, we need to create an empty variable to take the AccountId from the Record Triggered Flow. So, to create a variable resource, follow the below steps:
  • Click on the Manager tab, where you can see the New Resource option. Click on the new resource option.
salesforce auto launched flow

2. In the Resource Type field, select the Variable option. Then, enter the API Name as per your requirement.

  • Select Data Type as Text. The Availability Outside The Flow must be checked for Available for input. If you do not check it, it will not be available for input in the record-triggered flow whenever you choose it.

Then click on the Done button.

auto launched flows salesforce

3. Now, we create Opportunity records. To do so, click on the Add Element icon. Then select the Create Record option under the Interaction category.

auto launch flow salesforce

4. In the Create Record element, enter Label, and the API Name will automatically populate.

  • Select Manually set record field values and then select Opportunity Object to create a record of this object field.
  • Now, we need to set the field values for the opportunity fields. To do that, select opportunity fields in the Fields section and set the values for those fields in the Value section.
  • To relate the opportunity to the account record, In the Field section, select AccountId and set the created Variable(recordid) as Value to AccountId.
what is auto launched flow in salesforce

5. Click on the Save button to save this auto launched flow.

auto Launched flow salesforce example

6. Now, Activate the auto launched flow. We will use this flow as a Sub Flow in the record-triggered flow.

Auto Launched Flow in Salesforce

Edit Record Trigger Flow in Salesforce

Now, we need to edit it to add the created auto launched flow to this flow. To do so, open the record trigger flow in Edit mode.

1. In record triggered flow, click the Add Element after the Create Records Element, then select Sub-Flow action.

how to launch auto launched flow in salesforce

2. Select which flow you want to use as a Sub-Flow.

what is auto launched flow in salesforce

3. Enter the Label, and the API Name will populate automatically.

  • After that, in Referecned Flow, we need to set the input value for the Variable that we created in the auto launched flow.
  • To that resource variable, set the AccountId so that the opportunity record will be get associated with the account recordID.
how to call auto launched flow in salesforce

4. After that, Save the record triggered flow and then Activate the flow.

how to create a sub flow in salesforce

This is how we can create an auto launched flow in Salesforce and use it as a sub-flow in other flows.

Proof of Concept

1. Create a new Account record.

sub flow in salesforce

2. We created a Contact record in the Record Trigger Flow. You will see that the Contact record is also automatically created with the same contact name as the Account Name.

difference between auto launched flow and record trigger flow

3. Here, we Created an Opportunity record in the auto launched flow and used that flow in the Record Trigger flow as a Sub Flow; because of that, the opportunity record also gets created with the same opportunity name as the Account Name.

  • Here, you can also see we set some values for opportunity fields in the flow. Those are also reflected in the record.
create a sub flow salesforce

Conclusion

I hope you have an idea about creating an auto-launched flow in Salesforce. In this article, we have seen what an auto-launched flow is and when it can be used. Additionally, we have also seen how to create an auto-launched flow in Salesforce with the scenario.

We have also seen how we can use the auto-launched flow as a sub-flow in another flow, in that we have seen creating variables and using them in the sub-flow, and we have seen how to invoke an auto-launched flow in another flow.

You may like to read:

Agentforce in Salesforce

DOWNLOAD FREE AGENTFORCE EBOOK

Start with AgentForce in Salesforce. Create your first agent and deploy to your Salesforce Org.

Salesforce flows complete guide

FREE SALESFORCE FLOW EBOOK

Learn how to work with flows in Salesforce with 5 different real time examples.