How to use Subflow in Salesforce Flow

Hi folks, in this blog Iā€™m going to discuss how to use Subflow in Salesforce Flows.

To know more about Salesforce Flows and Flow builders you can check out What is Salesforce Flow Builder and basic Building Blocks of Flow Builder

Subflow are reusable Flows that can be called from other Flows, allowing you to break down complex processes into smaller, more manageable steps.

A Subflow element refers to another Flow and invokes it at runtime.

In this blog, I am going to create a screen Flow where the user will provide input to create a contact.

Subflow will be used in the main Flow to display the error if any when the contact is created.

The screen element is used to collect information from the user and is only available in a screen Flow.

To create a contact record using screen Flow we will take the Name, Email and Phone number as input from the user.

Now we will add the Create Records element to our Flow for creating the contact record.

While editing the CREATE RECORDS element we have the option to create a single record or multiple records using this flow.

Creating Contact Record

As we have limited fields as input, we will be using the “Use separate resources and literal values” option for creating the Contact record.

Mapping fields for creating Contact record

Now we will create another Flow to handle the errors we encounter while creating the Contact records.

This Flow will also be a Screen Flow as we are going to display the error messages to the user.

SubFlow

Now we will add this newly created Flow as Subflow in our main Flow.

Add SubFlow to Main Flow

To show dynamic error messages we will use {!$Flow.FaultMessage} as the input value for the error message.

This is an example of an error message we get when the user doesn’t insert the Last Name while trying to create a Contact record.

SubFlow Error Message

Want to Learn Salesforce Flows? Checkout our Salesforce Flow Course

Advantages of using Salesforce Subflow:

  • By reusing Subflow in different parent flows, the necessity of replicating the same steps multiple times can be eliminated.
  • By dividing a complicated process into smaller Subflow, you can simplify the design and make it easier to debug.

Use cases where you can use a Subflow:

  • Use subflow to automate the process of onboarding new customers, from collecting contact information to setting up their accounts and assigning a customer success manager.
  • Subflow can be used to automate repetitive tasks, such as sending follow-up emails, updating contact information, or creating tasks for team members.

For more details, check out the video below !!

Get a complete Roadmap To Learn Salesforce Admin And Development

Spread the love

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *