Skip to main content
Build the future with Agentforce at TDX in San Francisco or on Salesforce+ on March 5–6. Register now.
Geschätzte Zeit

Build the Flow

Understand Types of Flows

Flows are versatile tools for automating your processes.

For this project, we want our users to click a quick action to start the process, so we create a screen flow. A screen flow requires user interaction—clicking a button, entering information into a form, and so on—and can guide users through a process.

If we wanted this flow to send an automated message when a new program engagement is created, we would choose a record-triggered flow. If we wanted to batch send an email to all new program engagements at a set time each day, we would pick a schedule-triggered flow. Those are worth experimenting with on your own, but we stick with a screen flow in this project. (You can learn more about different types of flows through the links in Resources.)

Create Your Screen Flow

Let’s get started by creating a new flow.

  1. If you aren’t already in Setup, go there now. Click Setup () and then Setup.
  2. In the Quick Find box, enter flow and click Flows in the Process Automation group.
  3. Click New Flow.
  4. Make sure Start from Scratch is selected, and click Next.
  5. Select Screen Flow, the default, and click Create.

On your new flow, your page should include only two elements: Start and End with one Add Element icon between them.

Get Records

Let’s start building!

We begin by adding a Get Records element to the flow. This element finds our program engagement records and stores data in the flow, allowing us to use that data for different actions. 

In this case, we need information about the program engagement and our program participant, or client.

  1. On the flow canvas, on the path after the Start element, click Add Element.
  2. Click Get Records in the Data group.

  3. In Label, enter Get Program Engagements. The API Name should automatically populate as Get_Program_Engagements.
  4. In Description, enter Gets and stores data from a program cohort's related active program engagement records. Fill in your flow’s description fields to describe exactly what each element does. It helps you—and other admins—update the flow later.
  5. In the Object field, select Program Engagement (pmdm__ProgramEngagement__c).
  6. A new Filter Program Engagement Records section appears. This is where we select which program engagement records we want to retrieve and store. We only want active engagements related to the cohort record, so we filter that now.

    1. In the Condition Requirements field, leave the default value of All Conditions Are Met (AND).
    2. In the first condition row, enter these details to get the records included in the program cohort record you are on when you start the flow. Remember, this is a quick action on a program cohort record and you only want data related to the cohort where you launch the flow.
      • Field: pmdm__ProgramCohort__c (Program Cohort)
      • Operator: Equals
      • Value: Click into the field and then click New Resource.
        • Resource Type: Variable.
        • API Name: recordId. This is a special variable API name reserved just for the ID of the record on which you start the flow. Make sure the name is formatted exactly as recordId, with a capital I and lowercase d at the end.
        • Description: Stores the program cohort record ID.
        • Data Type: Text
        • Default Value: Leave this blank.
        • Select Available for input.
        • Click Done.
    1. Click + Add Condition.
    2. In the second condition row, enter these details to filter only program engagements in which the Stage field has an Active value.
      • Field: pmdm__Stage__c (Stage)
      • Operator: Equals.
      • Value: Active.
  1. Leave the Sort Order as the default, Not Sorted.
  2. In How Many Records to Store, select All Records.
  3. Leave the How to Store Record Data selection as the default, Automatically store all fields.
  4. Click Close.

Let’s recap what you just did. You used a Get Records element to find program engagements related to the cohort record where you started the flow, filtering to only program engagements with an Active value in the Stage field.

Get Records is super versatile, though, and you can configure your filters to get any set of records you would like. It’s worth learning about this element and its filters to find new ways to build flows. At the end of this project we review a few modifications to this flow for other uses. 

Save Your Flow

Now that we have at least one element in our flow, we can save it. As you work, be sure to save your flow frequently so you don’t lose progress.

  1. Click Save in Flow Builder.
  2. In the Flow Label field, enter Email Program Participants (Cohort). The Flow API Name should automatically populate as Email_Program_Participants_Cohort.
  3. In the Description field, enter Emails all program participants with active program engagement records included in a single program cohort.
  4. Click Save.

Loop Through Your Records

Now that we’ve retrieved the data we need with Get Records, we need to set up a loop to perform an action on each record. A Loop element helps us perform the same action for several records.

Let’s add our loop.

  1. On the path after the Get Records element, click Add Element.
  2. Click Loop in the Logic section.
  3. In the Label field, enter Loop Through Records. The API Name should automatically populate as Loop_Through_Records.
  4. In the Description field, enter Iterates the action for each of the records from Get Records.
  5. In the Collection Variable field, select Program Engagements from Get Program Engagements.
  6. In the Specify Direction for Iterating Over Collection section, select the default, First item to last item.
  7. Click Save in Flow Builder.

Add the Email Alert Action

With the loop in place, it’s time to set up our action: Sending the templated email.

  1. On the For Each path, click Add Element.
  2. Click Action in the Interaction section.
  3. In the Search… field, enter email and select the email alert we created, Send Email to Program Participants (Cohort).
  4. In Label, enter Send Email. The API Name should automatically populate as Send_Email.
  5. In the Description field, enter Sends an email to each program participant with program engagements in the program cohort using the Program Participant Welcome (Cohort) email template.
  6. In the Record ID field, click the Current Item from Loop Loop Through Records record variable—it has an arrow next to it ()—then select Record ID.

  7. Click Save in Flow Builder.

Add a Confirmation Message

By default, when you run a flow like this you receive a message that says YOUR FLOW FINISHED. That’s accurate, but not very reassuring or descriptive.

Let’s add a confirmation message to our flow. (If your flow is filling up the page, you can resize the canvas or drag your flow to where you can see the End element.)

  1. On the After Last path, click Add Element.
  2. Click Screen in the Interaction section.
  3. In the Label field, enter Confirmation Message. The API Name field should automatically populate with Confirmation_Message.
  4. In the Description field, enter Shows confirmation message that email has sent.
  5. Click Configure Header and deselect Show Header.
  6. Drag a Display Text component from the Display section of the Components pane on to the palette.
  7. In API Name, enter Confirmed.
  8. In the text field, enter Your email has been sent to clients on all active program engagements in this cohort. You could also use a resource here to display content from a variable, but we won’t do that now.

  9. Click Done.
  10. Click Save in Flow Builder.

Let’s Sum It Up

Our flow is now complete. To recap, we started by creating the flow and adding the records that store the information needed in the flow, and saved our work. Then we set up a loop for the actions to perform on each record, and followed by adding the specific actions and a confirmation message.

Click Verify here in Trailhead to check your work, then in the next step we activate the flow and add it to the Program Cohort page layout where it can be used.

Resources

Teilen Sie Ihr Trailhead-Feedback über die Salesforce-Hilfe.

Wir würden uns sehr freuen, von Ihren Erfahrungen mit Trailhead zu hören: Sie können jetzt jederzeit über die Salesforce-Hilfe auf das neue Feedback-Formular zugreifen.

Weitere Infos Weiter zu "Feedback teilen"