Skip to main content
3 月 5 日~ 6 日にサンフランシスコで開催される TDX (Salesforce+ でも配信) で「Developer Conference for the AI Agent Era (AI エージェント時代に向けた開発者向けカンファレンス)」にぜひご参加ください。お申し込みはこちら

Build the Flow

Understand Types of Flows

Flows are versatile tools for automating your processes.

For this project, you want users to click a quick action to start the process, so you 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 you wanted this flow to send an automated message when a new program engagement is created, choose a record-triggered flow. If you wanted to batch send an email to all new program engagements at a set time each day, choose a schedule-triggered flow. Those are worth experimenting with on your own—and you can learn more about different types of flows through the links in Resources—but let’s stick with a screen flow in this project.

Create Your Screen Flow

Start by creating a new flow.

  1. From Setup, in the Quick Find box, enter flows, and then select Flows.
  2. Click New Flow.
  3. Select Start from Scratch and click Next.
  4. Select Screen Flow, the default, and click Create.

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

The canvas only include Start, End, and the add element icon.

Get Records

Let’s start building!

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

In this case, you need information about the program engagement and your program participant, or client.

  1. On the flow canvas, on the path after the Start element, click Add Element.
  2. Find and select Get Records in the Data group.
    Get Records is the third option 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 you select which program engagement records to retrieve and store. You only want active engagements related to the cohort record, so filter that now.
    You will create two filter conditions.
    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. This will be 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. In How Many Records to Store, select All Records.
  2. Click Close on the Get Records pane.

The Get Program Engagements Get Records element appears in the flow canvas.

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, and you can configure your filters to get any set of records you want. It’s worth learning about this element and its filters to find new ways to build flows. At the end of this project we will review a few modifications to this flow for other uses. 

Save Your Flow

Now that you have one element in your flow, you 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. Save your work.

Loop Through Your Records

Now that you’ve retrieved the data you need with Get Records, you 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.

Add your loop now.

  1. On the path after the Get Records element, click Add Element.
  2. Find and select Loop in the Logic section.
  3. In the Label field, enter Loop Through Records. The API Name automatically populates 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. Save your work.

The Loop element creates two new paths with Add Element icons: For Each and After Last.

Add the Email Alert Action

With the loop in place, it’s time to set up your 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 you 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.
    The complete Action element settings pane.
  7. Save your work.

The Send Email Action element appears in the For Each path of the Loop.

Add a Confirmation Message

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

Add a confirmation message to your 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, don’t do that now.
    The New Screen window shows a preview of the screen.
  9. Click Done.
  10. Save your work.

The Confirmation Message Screen element appears in the After Last path of the Loop.

Your flow is now complete. To recap, you started by creating the flow and adding the records that store the information needed in the flow, and saved your work. Then you 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 you activate the flow and add it to the Program Cohort page layout where it can be used.

Resources

Salesforce ヘルプで Trailhead のフィードバックを共有してください。

Trailhead についての感想をお聞かせください。[Salesforce ヘルプ] サイトから新しいフィードバックフォームにいつでもアクセスできるようになりました。

詳細はこちら フィードバックの共有に進む