Skip to main content
Geschätzte Zeit

Communicate Using the Action Element

Learning Objectives

After completing this unit, you’ll be able to:

  • Build a flow that sends an email.
  • Use text templates to compose formatted messages that Flow Builder can use.
  • Build a flow that creates a Chatter post.
  • Build a flow that submits a record for approval.
Note

This badge is one stop along the way to Flow Builder proficiency. From start to finish, the Build Flows with Flow Builder trail guides you through learning all about Flow Builder. Follow this recommended sequence of badges to build strong process automation skills and become a Flow Builder expert.

It’s wonderful that you can use flows to create, update, and delete records, but it’s not always wonderful to do those things silently. Flows can also:

  • Inform one or more of your users of a change.
  • Help users send a notification to a customer.
  • Allow users to request approval of a change before it’s committed.

These are all forms of communication that you can automate with Flow Builder, ensuring that your users and customers have the information they need.

Introducing the Action Element

To make all this wonderful communication happen, you use one element: the Action element. Despite its basic name, this element has a wealth of superpowers, like a real action hero!

A comic book called Action Element featuring Flo Smith as a mighty superhero.

The Action element can communicate with users, customers, and external systems. It can also perform some advanced automation tasks, but in this module, we focus on communicating with people.

Send an Email with an Email Alert

The sales department at Pyroclastic wants to notify the account owner immediately when key details change in an account. Flo asks you to create a flow that emails the account owner when a change occurs.

There are multiple ways to send an email in a flow, but we recommend using the Action element to select an Email Alert workflow action. This method has the most features and is easy to set up if you have existing email alerts from workflow rules.

Note

Wondering why we’re talking about Email Alerts even though Salesforce is deprecating workflow rules? Email Alerts are workflow actions, not workflow rules. Actions are not being deprecated, and flows can use many of them, including Email Alerts.

If you don’t already have the email alert you need, create it first.

Create an Email Alert

  1. From the Activity tab on an account record, click Email button to create an email.
    • Subject: Account change notice
    • Body: Your account record has changed. Feel free to add more elaborate text or merge fields as you wish.
    • Related To: verify that an account is selected
  1. Click Insert, Create, or Update template and select Save as new template.
    • Template Name: Account Change
    • Folder: Public Email Templates
  1. From Setup, enter Email Alerts in the Quick Find box and then click Email Alerts.
  2. Click New Email Alert.
    The page used to create a new email alert, including the fields corresponding to the details that follow.
  3. For Description, enter Notify Owner of Account Change.
    Descriptions should be, well, descriptive, because it’s how you find the email alert you want in a long list of actions.
  4. For Unique Name, keep the default: Notify_Owner_of_Account_Change.
  5. For Object, select Account.
    Email Alerts are each tied to a specific object because the object defines the possible recipients. For example, because this email alert is related to the Account object, it has access to account-specific recipients such as Account Team members.
  6. Select an email template to use:
    • Click the magnifying glass (Email Template Lookup (New Window)) next to the Email Template field.
    • In the Lookup window, select Lightning and Public Email Templates.
    • Click the Account Change email template.
      The Lookup window corresponding to the preceding steps.
  1. For Recipient Type, select Owner.
  2. Under Recipients, move Account Owner from the Available Recipients list to the Selected Recipients list.
Note

Alternatively, you could select specific users, or change the recipient type to select dynamic users (such as a user field on the related record), or specify everyone in a specific role.

The Email Alert window corresponding to the preceding steps.

  1. Click Save.

Create a Flow That Uses the New Email Alert to Send an Email

Your email alert is ready to go. To build a flow that sends the email, follow these steps.

  1. Create a record-triggered flow:
    • Object: Account
    • Trigger the Flow When: A record is updated
    • Condition Requirements: Any Condition Is Met (OR)
    • In the Filter Records section, define conditions that tell the element which records to retrieve.
      • First condition:
        • Field: AccountNumber
        • Operator: Is Changed
        • Value: $GlobalConstant.True
      • Second condition:
        • Field: AnnualRevenue
        • Operator: Is Changed
        • Value: $GlobalConstant.True
      • Third condition:
        • Field: Name
        • Operator: Is Changed
        • Value: $GlobalConstant.True
      • Fourth condition:
        • Field: Rating
        • Operator: Is Changed
        • Value: $GlobalConstant.True
  1. On the flow canvas, on the path after the Start element, click Add Element. Select Action.
    (When you’re in a record-triggered flow, you can instead click Send Email Alert. Then the only Actions available are email alerts.)
  2. In the Search… bar, type emailAlert to display a list of the available email alerts, then select Notify Owner of Account Change.
  3. For Label, enter Email Account Owner.
  4. For Record ID, select Triggering Account > Account ID.
Note

It’s important to make sure you choose the right related record. It determines the record that stores the email in Salesforce, but most importantly, it also channels that record's values into the email template’s merge fields. For example, if your email template uses the {{{Recipient.Name}}} merge field to add the email recipient’s name into the email text, {{{Recipient.Name}}} is replaced with the name of the contact you select here.

The New Action window, with an email alert workflow action selected, and showing the fields corresponding to the preceding steps.

  1. Save the flow. For Flow Label, enter Send Email on Account Change.

And there you have it! Your flow can now speak the language of email.

Post to Chatter

If sending an email isn’t your style and you’d rather send a message within Salesforce, you can use the Action element to create a Chatter post. You can post to a record, a Chatter group, a user’s feed, or any other place that has a Chatter feed. But first, you need two things.

  • A text template that contains what you want to post
  • A resource that contains the ID of the place where you want to post

Because this flow will do the same thing as the Send Email on Account Change flow, we’ll edit the Send Email on Account Change flow and then save it as a new flow.

The Text Template, Your Communication Friend

Because you can’t type a long, formatted message into the Action element directly, you need something else to store that message. That’s when the text template becomes your communication friend. 

In Flow Builder, text templates are resources that can contain a chunk of text. The text can be one word, one sentence, or many paragraphs, and can contain merge fields.

Note

By default, text templates are in rich text format, which is great for adding formatting and images to your text. Unfortunately, when a Chatter post uses a rich text template as the body, it adds unwanted HTML tags to the message. For Chatter posts, make sure you set the text template to View as Plain Text.

Create a Text Template

  1. In the Send Email on Account Change flow, if the Toolbox isn’t already open, click Toggle Toolbox to open it.
  2. Click New Resource.
  3. For Resource Type, select Text Template.
  4. For API Name, enter ChatterBody.
  5. Next to the Resource Picker field, change View as Rich Text to View as Plain Text.
  6. In the Resource Picker field, select $Record > OwnerId.
    A merge field for the owner’s name is inserted at the beginning of the message body.
  7. Add square brackets [ ] around the merge field, like this: [{!$Record.OwnerId}]
  8. Add an @ symbol at the beginning, like this: @[{!$Record.OwnerId}]
    When followed by a value enclosed in square brackets, the @ symbol inserts the value as a mention in the Chatter post.
  9. After the closing bracket, enter , your account record has changed.The New Resource window, corresponding to steps 3–8.
  10. Click Done.
  11. In the button bar, click Show Menu next to the Save As New Version button and select Save As New Flow. This option avoids overwriting the Send Email on Account Change flow.
  12. For Flow Label, enter Post to Chatter on Account Change.
  13. Click Save.

Your new text template can now be referenced in any Flow Builder field where you can select a text resource.

Create an Element That Uses the New Text Template to Post to Chatter

  1. If the Post to Chatter on Account Change flow isn’t already open, open it now.
  2. On the flow canvas, click the Email Account Owner element and then click Delete Element.
  3. On the flow canvas, click Add Element. Select Action.
  4. In the Search… bar, enter post and then select Post to Chatter.
  5. For Label, enter Chatter Notification.
  6. For Message, select the ChatterBody text template.
  7. For Target Name or ID, select Triggering Account > Owner ID > Username.
Note

In the Target Name or ID field, you can enter the ID of a record, user, or Chatter group where the post should appear. If the target is a user, you can instead use their username. If the target is a Chatter group, you can instead use the group’s name.

  1. Enable Target Type to include the Target Type field on this Action element.
  2. For Target Type, enter User.
    Because the Target you entered is a user, you must enter User as the Target Type, even though it doesn’t appear as a suggested option. If the Target were a Chatter group, you’d enter Group. When the Target is a record, you can leave Target Type disabled.
    The New Action window, creating a Post to Chatter action with the fields corresponding to the preceding steps.
  3. Save the flow.

Voilà! Your flow now speaks Chatter quite eloquently.

Submit a Record for Approval

Pyroclastic’s sales teams rely on approval processes to request management approval for opportunity discounts. But Flo hears through the grapevine that salespeople sometimes forget to click the Submit for Approval button when a deal is ready. Wouldn’t it be great if the opportunity were automatically submitted for approval when it reaches a certain stage? It can be, using flows!

Take a guess: Which element do you use to send approval requests? 

That’s right, the Action element. Before you create an action to send approval requests, you need:

  • An active approval process
  • A variable or other resource that contains the ID of the record to be approved
  • Optional:
    • A text template with the text to be sent to the approver
    • A variable or other resource that contains the ID of the submitter

Follow these steps to build a flow that submits a record for approval.

  1. Create a record-triggered flow:
    • Object: Opportunity
    • Trigger the Flow When: A record is created or updated
    • Condition Requirements: All Conditions Are Met (AND)
    • Field: StageName
    • Operator: Equals
    • Value: Proposal/Price Quote
    • When to Run the Flow for Updated Records: Only when a record is updated to meet the condition requirements
    • Optimize the Flow for: Actions and Related Records.
  1. On the flow canvas, on the path after the Start element, click Add Element. Select Action.
  2. In the Search… bar, type submit and then select Submit for Approval.
  3. For Label, enter Request Opp Approval.
  4. For Record ID, select Triggering Opportunity > Opportunity ID.
  5. Enable Approval Process Name or ID, and enter PriceQuoteApproval.
    If you leave this field blank, the flow follows the normal method for determining which approval process to run: the first active approval process on the current object whose entry criteria are met.
Note

Flow Builder doesn’t validate that the approval process exists. For the purpose of this badge, we’re using an imaginary approval process. You can’t test this flow because when you try to run it, it will fail.

  1. Enable Submitter ID, and enter Triggering Opportunity > Owner ID.
    Use the Submitter ID when you want someone other than the user who ran the flow to be the submitter. If the submitter isn’t an allowed submitter for the approval process, or the selected approval process has entry criteria that aren’t met, the flow fails.
    The New Action window corresponding to the preceding steps.
  2. Save the flow. For Flow Label, enter Price Quote Approval.

Congratulations, your flow is now fluent in multiple forms of communication! In the next unit, you learn another way to retrieve data that can help with your flow’s communication.

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"