Adding a Subflow element to a Flow

Subflow is a way to call an existing Flow from another Flow. In other words, you can say that Subflow is based on reusable component concepts; for example, you can use components in any Visualforce page. The benefits of components are that you only have to create it once and you can use and refer to it in multiple places.

Let's look at a business scenario. Sara Bareilles is working as a system administrator at Universal Containers. She has created a Flow for Opportunity creation in the previous example. She received an additional requirement (keep the previous requirement in your mind; at the end, we will use Process Builder to complete it) to auto-add the new Opportunity to Sales Executive Chatter group 1 hour after Opportunity creation.

You can now share records with Chatter groups. There are numerous ways in which you can solve the preceding business requirement, such as the following:

  • Process Builder
  • Modifying the existing Flow and embedding it into a Visualforce page
  • Apex trigger

We will use Subflow and Process Builder to resolve the preceding business scenario. Perform the following steps to solve the preceding business requirement:

  1. In the Lightning Experience, navigate to Setup (Gear Icon) | Setup | PLATFORM TOOLS| Feature Settings | Chatter | Chatter Settings and make sure that the Allow Records in Groups checkbox is selected, as shown in the following screenshot: 
  1. Navigate to Setup (Gear Icon) | Setup | PLATFORM TOOLS | Process Automation | Flows.
  2. Click on the New Flow button; it will open the Flow canvas for you.
  3. Create three Text variables: VarTNew_AccountId, VarTNew_AccountName, and VarTNew_OppId, and set Input/Output Type to Input and Output for all the variables.
  1. Click on the Palette tab, navigate to the FLOWS section, and drag and drop the Create new Opportunity Flow onto the canvas; it will open a window, where you have to enter the following details:
    • Name: Enter the name for the Subflow element. In this case, enter Create an Opportunity as the name.
    • Unique Name: This will be autopopulated based on the name.
    • Description: Write some meaningful text so that another developer or administrator can easily understand why this Subflow was used.
    • Input/Output Variable Assignments: Use this section to set values for input and output elements.
      • Input: Click on the Inputs tab to assign values or elements from the master Flow to the variables in the current or referenced Flow. In this case, we will use the VarTNew_AccountId and VarTNew_AccountName variables to pass the values in the referenced Flow variables, as shown in the following screenshot:

        In the referenced Flow, we have to pass the account ID and the account name to create an Opportunity.

      • Outputs: Click on the Outputs tab to assign variables from the referenced Flow to the variables in the master Flow. Here, we will save the ID of newly the created Opportunity in the VarTNew_OppId variable, so you can use it later in the Flow. It will look like what is shown in the following screenshot:
  1. Once you are done, click on the OK button.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.166.90