The lightning:flow component is commonly inserted into aura components to enable screen flows to run when those components are rendered. What if you want to insert a flow into your own LWC component?If you’re building an LWC, you can’t currently just invoke lightning:flow because it has not yet become available in an LWC version (and LWC doesn’t allow Aura components to be inserted).
To address, that, the ScreenFlow LWC installable from this page provides a way to insert a flow into your own LWC container. Simply invoke it in your LWC like this:
When your component instantiates, it will load the named flow into an iframe created with the specified height and width, and pass in any input params you provide.
How It Works
Getting this to work required a bit of bricolage. When ScreenFlow initializes, it sets up some message-passing infrastructure and determines the org URL. It then renders an iframe and passes to that iframe the name of a visualforce page called screenFlow that’s provided in this package. The URL that loads the screenFlow page also contains query parameters with any input parameters.
The visualforce page has script on it that creates a lightning:flow aura component and then sends it a start flow command. More event infrastructure is put in place so that when the lightning:flow generates some sort of status change, the event it fires gets passed up to the visualforce page, where it’s converted into a message that get passed across the iFrame boundary to the parent screenFlow lwc, which will dispatch an event (“flowstatuschange”) with any output data. Your container can register to receive flowstatuschange events so it can receive the output values of the flow.
Jack Pond has added major improvements to email sending via Flow with Send Better Email โ Flow Action. This action replaces all previous rich/html Flow actions. Most notably, the new action features a custom property editor, providing easier configuration:
Jack has also added new support for Salesforce’s Mass Email sending service. This substantially increases the amount of email you can send with a single Flow.
You can now independently choose whether you want your email sends to be recorded as activity history and/or tasks. Additionally, you can now specify a desired email template by name. The action will now return a list of created task ID’s if you choose to have tasks created.
For installation, we’ve chosen to change the name of the action to Send Better Email. That means that its installation won’t be blocked by the existence of older Send Email actions. In general we seek to keep the name the same and enable seamless upgrade, but in this case there were too many changes. Going forward, though, we hope to provide improvements in a way that can just be updated in place without aggravation.
I’m very pleased to again be able to share information about imminent new Flow functionality! This is a particularly strong release, possibly a match for the already-legendary Winter ’20 release. Preview Orgs can be obtained to try out this functionality.
Flow Canvas ‘Autolayout Mode’
Flow Builder now provides a canvas option called Autolayout that automatically connects elements to each other and handles layout. This simplifies the user experience and makes flow construction more consistent.
Use the new Autolayout toggle on the Flow Builder header to switch between Autolayout and the traditional Open Canvas mode:
Autolayout mode does not currently support flows where a single non-Loop element has more than one inbound connector or where a single Loop element has more than 2 inbound connectors.
When changing to Autolayout mode, if the current was created in Open Canvas mode, its positions will be lost, even if the user immediately changes back. We therefore recommend that users save before activating autolayout mode if changes are intended. However, if the flow is changed to autolayout mode and then closed without any saves, the original positions will still be present in the latest version.
We’re going to be very interested in feedback on the Autolayout experience because we don’t want to indefinitely maintain both modes and we think Autolayout is the future.
Trigger on Delete
Needs no explanation.
Universal ‘OR’ and ‘Custom Condition Logic’
You can now use actual OR logic. Oh, and Custom Condition Logic too. Everywhere in Flow. The ‘smart money’ on the Automation teams thinks this might be this release’s most popular new feature, despite the tough competition.
Multi-Column Screens (Open Pilot)
Enable this pilot to see a new component in Screen Builder: Section. Each section can be divided into up to 4 columns. Customers can use Sections to create multi-column layouts on their screens, and then embed whatever screen components they like in those components.ย
This enables you to do a debug run as a specified user. Great for testing.
This can be controlled at the org level:
Note:
Not available in production. Test your Flows in sandbox, please!
Does not affect API calls made from client-side components, such as Flow screen components.
Visual Debugging for Autolaunched Flows
A number of debugging improvements have been rolled out for autolaunched flows:
Note the reorganized Debug Log, the improved header, and, most prominently, the visual path indicators.
Pills
Some parts of Flow Builder have been enhanced to feature pills, which allow friendly labels to be used in place of merge field syntax.
Click on a pill to reveal its underlying value. Pills do not change existing values in any way. They simply add a label.
For example $GlobalConstant.True will appear as โTrueโ
We’ll be expanding the range of pills support in the next release.
Directed Error Messages
Error messages now provide, when available, links to the element that caused the error, allowing the property editor to be quickly opened.
Insider tip: one of the reasons we did this was to pave the way for the conversion of modal property editors into panel property editors that allow you to create an element and leave it partly unconfigured without triggering error messages. The validation moves to Save-time, which makes it important to help users ‘get back’ to the source of errors. This in turn is a prerequisite for true Draft Mode.
Record Update Trigger Improvements: Query Filters
A number of Process Builder capabilities comes to Flow in this release. Now, when you create a record-update triggered flow, you have the option to select entry criteria to narrow down which records youโre automating in the first place. The Process Builder choice to only run when the criteria has just changed to meet the requirements is also now available:
Record Update Trigger Improvements: ‘Only When Record Has Just Changed’
As seen above, the ‘When to Run the Flow for Updated Records allows for tighter control of execution.
Record Update Trigger Improvements: Traversal to Related Records
It’s hard to write something catchy about field traversal. It’s just one of those things that you don’t think about until you absolutely must have it. Now available in Record-Change Triggers.
Import Flow Actions for Public Web Services Like Jira, Trello and eBay with External Services (PILOT)
External Services, which I think of as ‘API Action Builder’, has been enhanced to support OAS 3.0 and schemas up to 1 million characters in size. The biggest impact of this is that, for the first time, it’s possible to use External Services to bulk import the ‘schemas’ (basically a big text file describing APIs that you can call) of public web services, generating dozens of Flow Actions that directly access those web services’ APIS.
Not all web service schemas can be imported in Winter ’21. Some are longer than the current 1 million character limit. Others produce errors when you try to ingest them because of functional gaps that still need to be addressed. However, as you can see from the image above, the list of services that you can successfully ingest includes Jira, Dropbox, Instagram, Twitter, Mailchimp, eBay, and Walmart, GoToMeeting, Trello, and Medium. Here are some examples of the actions that become available for use in flows:
Note that this currently planned as a closed pilot, meaning you need to request access via your company’s Account Executive.
Expanded Access to Global Variables
Global variables, previously only available in Flow via Formulas, are now accessible anywhere you want to reference a field.
Flow API Versioning
For enterprises, this is the sleeper feature with the big impact.
Traditionally, changes that can cause breaking disruption have been deployed as CRUC’s that have to be carefully regression tested:
For a variety of reasons, this is burdensome, so starting with this release, the Flow engine will be versioned with the API version. Features that are deemed to have disruptive impact get versioned, which means they only are applied automatically to new flows. (Importantly, we expect that most flow enhancements will not have any breaking impact and will not need to be versioned.)
For your existing flows, you can decide on a flow-by-flow basis when to upgrade to a new version with a new version setting:
So essentially, you will no longer need to apply CRUC’s to your mature flows.
This release contains 4 versioned improvements:
Remove unintended Next navigation from flow screens at the end of a Flow that shouldn’t be showing a Next button Eliminates a scenario where the Next button displays even though the ‘Next or Finish’ checkbox in a Screen element’s property editor is unchecked
Record Variables no longer cause an error if they are used in a merge field and have a ‘null’ value
The ISBLANK function returns true for empty strings and not just for null values.
Enforce the running user’s data access rights when evaluating Flow formulas
So, to reiterate, the above four bug fix/improvements will only automatically apply to Flows that use version 50 or higher. All flows that were last saved on a Summer ’20 or earlier org will be assigned version 49.
Now GA: Screen Components can use Generic SObject attributes
Invocable Actions (aka Flow Actions) already have this functionality at GA level.
Custom Property Editor Enhancements
Custom Property Editors for Flow Screen Components is now Generally available. Custom Property Editors for Flow Actions (Invocable Actions) remains at Beta, but the only work remaining is some minor packaging enhancement.
You can now use Custom Property Editors with Actions and Screen Components that use inputs of type SObject or SObject[]. This opens up the use of Custom Property Editors to screen components like the Datatable shown above and actions like the Collection Actions. This is called Dynamic Type Mapping and you can learn about it here.
Agents are now empowered with contextual, event-based recommendations in the Next Best Action and the Actions & Recommendation components based on information in Voice Call records and call transcripts. Events for call state changes, such as start call, end call, mute, hold, etc.,can be used to build event-driven solutions.
APIs in the Service Cloud Voice Toolkit can be used to push context-sensitive recommendations based on field values in the call record and keywords in the call transcript.
Next Best Action is invoked with key:value pairs in the Lightning Message Service message payload. The value given to a particular key can be retrieved in the Recommendation Strategy using $Request.key in the filter element as follows $Request.key != ” && CONTAINS(Name, $Request.key)
Next Best Action has been certified compliant with HIPAA (the Health Insurance Portability and Accountability Act of 1996), certifies that NBA meets the strict standards for protection of sensitive customer information.
Einstein Recommendation Builder
Einstein Recommendation Builder (ERB) allows admins to recommend or match records from one Force.com object to another, using an AI-powered recommendation engine. It offers a point-and-click interface to support standard and custom matching problems using CRM data
Next Best Action (NBA) Integration
ERB is natively integrated with Einstein Next Best Action to surface these AI-driven recommendations as next best actions.
Other Winter ’21 Changes
Text Template resources now remember whether you’re viewing in Plain Text or HTML mode. This helps avoid situations where users were inadvertently entering HTML markup into their text.
The Flow home page list view now shows the Trigger Type of each flow.
Labels show up in Flow Interview Logs.
Newly enforced security restrictions on guest user access mean you need to activate the recently implemented permission elevation to ‘System Context without Sharing’ if you want Guest Users to have access to flows that use the Next Best Action Recommendation object.
When a user changes the owner of a record via Salesforce Classic, that record change can now launch a record-triggered flow
I recently made a big learning about the difference between managed and unlocked/unmanaged packages: when a user tries to install an unlocked package, all of the tests are run, but when a user tries to install a managed package, the tests are not run.
This prevents managed package tests from interfering with validation rules on the target org.
What we were seeing with typical unmanaged packages on UnofficialSF: the developer would write tests but customers trying to install the package to their production org reported installation failures because the tests create test records like Accounts or Contacts, and these record creates were failing for miscellaneous reasons (missing a custom field that is required on that particular user’s org, for example).
I asked the product manager of Apex, Chris Peterson, who wrote:
ย I would absolutely recommend managed to make it so that your flow-centric admins don’t end up owning Apex tests they can’t maintain). If they want the source they can grab it off github, but managed packages should be your “easy turn-key” option.
For managed packages: the tests run on pkg creation, and only run on install when the test is explicitly annotated requesting this. Managed tests are NOT run on metadata deployments to the org, unless specifically requested.
For (1st gen) unmanaged packages: this is a real problem, and one of many reasons why I generally discourage the use of 1st generation unmanaged packages entirely.
For 2nd gen unlocked packages: I have less experience, and if this is what you’re asking about let me know and I’m happy to go do my homework, since I should probably know this anyways.
At the end of the day, it’s not possible to make a test that does any DML that will succeed anywhere, at least not practically. Using the right delivery mechanism to ensure test ownership is assigned correctly (i.e. to you, the provider for managed, instead of to your subscriber for unmanaged) is by far the superior option to trying to make a “works anywhere” test.
As a result, we’ll be switching to managed packages wherever possible on UnofficialSF.
https://unofficialsf.com/wp-content/uploads/2022/09/largeUCSF-300x133.png00Alex Edelsteinhttps://unofficialsf.com/wp-content/uploads/2022/09/largeUCSF-300x133.pngAlex Edelstein2020-08-13 19:31:172020-08-13 19:31:23Developer Packaging Guideline – Managed Packages help you avoid installation failures
Trying to report on user login history using standard Salesforce reporting can be tricky. If you would like to see each users’s last login and his total login count for the last 6 months, sorted by login count, you have to use some external Excel manipulation. I was looking to get a simple report I could use to monitor login usage.
Simple Login Report
I was able to provide a nice solution using the new before save flow record trigger. The first step is to create a number field on the user object to hold the login count. Then create this simple before save flow. This flow updates the custom field on the User object. By incrementing a counter every time a login history is generated, each user shows a login count. Then, at any time, you can generate the report by simply reporting on your users.
User Login History FlowGet Login History RecordsConfirm records are returned (Null Check)Use the record count operator to assign the record count to the user fieldIf no records are returned, assign zero login count
This use case can be easily adapted to rollup any related records on other objects. I can think of several examples: count of opportunity contact roles on opportunity, count open cases on a contact, count of won opportunities on an account.
https://unofficialsf.com/wp-content/uploads/2022/09/largeUCSF-300x133.png00Tamar Erlichhttps://unofficialsf.com/wp-content/uploads/2022/09/largeUCSF-300x133.pngTamar Erlich2020-08-12 15:43:282020-08-12 16:39:53Flow Use Case – Use Before Save flow to update the total login count on the user record
Send Better Email is the latest and best email action for Flow, replacing previous versions of Send Rich Email and Send HTML Email.
It provides easy access to Salesforce’s single and mass email services, taking the place of Flow’s built-in Send Email action, which is currently something of an underachiever.
Features
This flow action supports:
Rich HTML email bodies that can use all of the capabilities of Flow’s Text Templates, including Bold, Italics, Underline, Bullets and Numbers, Left/Center/Right justification, URLs, images, fonts, and text size
Email Templates (both Classic and Lightning) with field merge and letterheads
Any combination of the following input sources, for To, CC, and BCC
A single email address
A string collection of email addresses
A collection of Contacts
A collection of Users
A collection of Leads
Organization-Wide Email Addresses
Attachments
Ability to toggle on/off the use of the Salesforce per-user email signature
Ability to provide a plain text body, an html body, or both
Ability to set the ReplyTo email address and the Sender Display Name
Multi-Language Support for Lightning Email Templates
Bulk Email (for advanced use and users)
In addition, this action provides access to Salesforce’s Mass Email services. These don’t provide as much configurability but allow for greater manageability and throughput.
Currently unsupported features include:
Character Set setting
If you’re interested in extending this class, please do so!
Video introduction (This is old and doesn’t reflect the current UI, but still has useful guidance on how to use the features)
This Action greatly expands the range of what you can do with Flow and email, but keep in mind that Flow is not optimized to serve as a mass email marketing solution. Despite the range of options provided here, you may hit system limits. Consider Marketing Cloud for large volumes and specialized needs.
NOTE: Scratch/Sandbox/Development orgs have very limited volume and recipient restrictions (example, scratch orgs have strict cutoff after sending just 50 email messages) and may allow as few as 10 external email addresses per day. Your production org will vary significantly, and issues related to limits in development do not necessarily correlate with production environments.
Configuration
Salesforce provides two kinds of email service, referred to here as Single Message and Mass Message modes.
Choose Standard or Mass Email for Action
In a nutshell:
Standard Email – The preferred choice. When in doubt, select this option. It provides far more powerful customization options for recipient selection (including the use of standalone text email addresses), message formatting, and more. However, this mode limits the number of recipients (150) per message and the number of different messages per invocation (10) you can use.
Mass Email – If you’re sending the same message to many recipients of the same object type (e.g., contacts, leads, or users), and you’re comfortable being required to use an email template, this mode provides you with greater throughput.
You can change between the two, but the parameters are very different, so changing the mode is almost a complete “configuration from scratch” process.
Sender Settings
These parameters are related to the sender of the message.
Set Sender Settings
You can either 1) use an OrganizationWideEmailAddress or 2) specify your own Reply-To Email Address and Sender Display Name. If you provide an OrganizationWideEmailAddress, that will take precedence and any Reply-To Email Address and/or Sender Display Name you’ve also provided will be ignored.
Sender Display Name
Optional. The name that appears on the From line of the email. Don’t attempt to set this if you’re also using an Organization-Wide Email Address with a defined DisplayName field.
NOTE: By default, the message will usually appear to be coming from (Example): noreply@salesforce.com; on behalf of; Do Not Reply <donotreply.example.com> . Changing this involves your email domain settings, outside of Salesforce.
Organization Wide Email Address
Optional. The ID of the organization-wide email address associated with the outgoing email.
Note: The object’s DisplayName field cannot be set if the Sender Display Name field is already set.
To use an Organization-Wide Email Address , pass the Id of one that you have defined into the action via the “Use This Organization-Wide Email Address Id”. (If you want to get the benefit of Verified sending, you can’t just paste the email address into the Reply-To Email Address field. You have to use the Use This Organization-Wide Email Address Id field.). You can locate the ID in the URL of an Organization-Wide Email Address (it starts with ‘0D2’):
Sender receives BCC of first email sent?
If selected, the user running the Flow receives a copy of each email that is sent.
Reply Email Address
Optional. The email address that receives the message when a recipient replies. Can not be used at the same time as an Organization-Wide Email Address.
Use Salesforce Signature if executing user has one?
Each Salesforce user can set up their own signature in their personal settings:
If this checkbox is set, the user’s signature will be appended to the bottom of the email. The default is now false, as of version 2.0.4. Previously it defaulted to true.
MessageId List of existing email if this is InReplyTo
Sets the optional In-Reply-To field of the outgoing email. This field identifies the email or emails to which this email is a reply (parent emails). This is a collection of strings which are joined to populate the In-Reply-To field in the message header. Example: In-Reply-To: <Fbg5P000000000000000000000000000000000000000000000QOMSGC00gRACvieGTKiHyEKz5Cywdw@sfdc.net>
Set Addressees
You can use the following data sources:
A single text email address
A string collection of email addresses
A collection of Contacts
A collection of Users
A collection of Leads
To simply type in a text value, select “String Variables (or type an address)” in the Search existing Flow resources, type the value you want to use, and click Search
Add a new address as a string
Subject and Body
You can directly configure the subject and body or alternatively use a Lightning or Classic Email Template.
Subject
NOTE: If you manually specify a Subject and select Use Email Template, your specified subject value will override the Template’s specified Subject. Emails without a subject (either specified or part of the template) will not be sent/delivered.
Specifying the Email Body
You can create static or custom bodies, and can use plain text and/or rich, HTML text. You can type the text directly into the HTML Body and Plain Text body fields, but it’s generally better to create Text Template flow resources and craft your body there, and then select the Text Template from the HTML Body and Plain Text combo boxes.
Rich Text HTML email bodies can use all of the capabilities of Flow’s Text Templates, including Bold, Italics, Underline, Bullets and Numbers, Left/Center/Right justification, URLs, images, fonts, and text size.
Example:
Text Template Resource named “HTMLTextTemplate”HTMLbody Parameter in sendBetterEmail Action
Plain Text (Body)
Not everyone has HTML email access, so even when youโre sending out an HTML email, it’s wise to also specify a plain text version. You cannot use plainTextBody and a template.
Previous versions of SalesForce allowed for templates which automatically attached text-only versions in the event a recipient did not desire and/or have the capability to use HTML-based email. As of this writing, it appears the Lightning Email always sends the HTMLBody, but does not attach the plainTextBody.
Using an Email Template
Email templates with merge fields let you quickly send emails that include field data from Salesforce records like contacts, leads, or opportunities and simplify the design and approval process for professional communication in appearance and content. You can use email templates when emailing groups of peopleโ mass emailโor just one person.
WARNING: If you are using an email template, do NOT put any value in the Subject field. Doing so causes the email template to basically be blanked out.
If you choose to use an Email Template, you can specify it by either its Id or Name, but you cannot provide both:
This actions has advanced capabilities to support multi-lingual templates. If you’re using this, you must use Template Name with the Template Language. For further details see section – Using Email Templates. Lightning Email templates (accessed by Apps–>Email Templates) are recommended for this language feature.
Email Template Id – You can get the Template Id from the Email Template URL. The Id would be ’00X2F000001RDHPUA4′ in the below example.
Finding Email Attribute for Parameters
Template Name – The name of the Template (In the above example, ‘sendHTMTest’). If you have multiple Templates with the same name, the Action will select the first one.
Treat the target as a recipient. Defaults to True – Optional. If set to true, the targetObjectId (a contact, lead, or user) is the recipient of the email. If set to false, the targetObjectId is supplied as the WhoId field for template rendering but isnโt a recipient of the email. The default is true. An example of when this might be when the email is to be sent to a recipient about a target person in relation to another record. If set to false, the recipient ID would be used but the email would not be sent to te TargetId whose information (and that of the related object) can be used for merging without sending the email to the TargetId.
Template Language – To use this field, add the phrase ‘Language =”[language name]”‘ to the Description field of your email templates. If you specify a Language in tht eTemplate Language field, it will , it will look for the first Template with a matching “Language” tag in the Email Description field.
Recipients & Recipient-Related Records
This section only appears when you’re using a template.
Recipient Record Id (also for template merge fields and recording related Email as an activity)
Required if using a template. The ID of the contact, lead, or user to which the email will be sent.
Related Record Id (for template merge fields and/or recording Email as a task)
The ID of a record associated with the recipient.
This value must be the record ID of one of the following object types:
Account
Asset
Campaign
Case
Contract
Opportunity
Order
Product
Solution
Custom
This field essentially allows the template to draw merged values from two records: that of the recipient and that of a separate record.
Attachments
You can attach files to your emails using a collection of ContentDocumentLink records. To learn how to attach documents using Content Document Links, see this.
Record as Activity and/or Task
Note: Using this feature does require a record access/query which will be counted for limits).
Save Email as Activity on Recipient Record(s)?
If you used a collection of records (or a single Recipient record Id) as the addressee(s), this will cause the email send to be recorded as an Activity on that recipient record.
Save Email as Task on recipient related record(s)?
If selected, a Task will be created on the Related Record (not on the Recipient Record).
Mass Email Configuration
When you set the Email Type to ‘Mass Email’, you get to configure fewer things but you get some monitoring capabilities including the ability to cancel sends and get notified when sending is complete. To begin with, you must use an Email template to specify your email content.
Set Sender Settings
With the following exceptions, these values behave the same as in the Single Email example above.
Description included in status email
Organization-wide Addresses are not available
Mass Email Sender Settings
Description (sent in internal email with status after action completes)
When you use Mass Email, a summary report gets sent to the running User upon completion of the sending. The body of this message will include the value specified in the Description input. It is used so the receiver (usually an admin) can distinguish which Action this came from. It should not be confused with the Email Template Description.
Email Template
This section behaves the same as in the Single Email case, described above.
Specifying Recipients
Mass Email requires the use of recipient and related record collections
Recipient Record Id Collection – To specify recipients, pass a collection of Contacts, Leads, or Users to the “Recipient Record Id Collection” input.
Related Record Id Collection – Use this only if you are providing a collection of Contacts for Recipient Record Id Collection. If you use it, it must: 1) match the number of Contacts in umber and 2) be from one of the following: Contract, Case, Opportunity, Product. Essentially, this surfaces additional merge field options in the Template.
Record as Activity and/or Task
When sending a communication, you may wish to keep a record that a communication has been sent. To do so, you can use one or both of the following. Note: Using this feature does require a record access/query which will be counted for limits).
Save Email as Activity on Recipient Record(s)?
If selected, the sent email will be recorded as an Activity on the corresponding Recipient Record (not on the Related Record).
Save Email as Task on recipient related record(s)?
If selected, a Task will be created on the Related Record (not on the Recipient Record).
Output Values
Both Single and Mass Email return values that can be used later in the flow.
errors
A string which reports back the last error encountered in executing the action. In the event a successful send occurs, errors on subsequent events (such as adding a task or email activity) may be reported here, but isSuccess would still return true.
isSuccess
A boolean that indicates the success or failure of this Action in executing the send email. In the event a successful send occurred, errors on subsequent events (such as adding a task or email activity may be reported in the errors), but isSuccess would still be true.
taskIds
If “Save Email as Task on recipient related record(s)?” has been selected, this is a returned list of TaskIds that were successfully created. If an error occurred for the individual task, instead of an ID, it will return a string starting with “ERROR: ” followed by the error message.
templateUsed
In the case where a Template name was used instead of a specific id, this parameter returns the Id of the template actually used. This is useful if the process maintainer wishes to know which language template was used (in the case of language localization) or which template was selected if the org has multiple templates of the same name
Use Email Templates to save time and standardize email sent by you or others in your organization. Use merge fields or enhanced letterhead to customize the content and/or appearance of the communication. Details on how to use EmailTemplates in multilingual environments can be found here.
There are 3 core components of an email template:
The Template. The template contains the format of the email (including Letterhead) and syntax for merging fields into that communication. A merge field is a placeholder in an email template or letterhead. When you send the email, the placeholder is replaced with the Salesforce data from the record or records of the people you are emailing. Fields that can be merged include those from the TargetObject, another sObject record, and global variables. NOTE: the merging done by the template system is different from the merging done by Flow, and there is currently limited ability to pass dynamic values from Flow into the template system. HOWEVER, see this post for an easy technique that will allow you to get full rich dynamic merging.
The Target Object Record. This is who the email is being sent to, usually a Contact, User, Lead or Group. Depending on the type of template you are using, other fields from this Target Object can also be merged into the template as part of the send email (e.g., Dear Dear {{{Recipient.Name}}}). In email templates, the merge fields for “recipient” come from the specified object Id.
The Related Record(for Contacts only). If you specify a Contact for the Target Object field, you can specify an optional Related Record to merge fields in the template from that record. For the most predictable results, Use the Handlebars Merge Language in Lightning Email Templates and Enhanced Letterhead which merges fields from the record into the email using the format {{{[Related Record Type].[Field]}}} (e.g., {{{Case.CaseNumber}}}), and convert your Classic Templates to LightningEmailTemplates with Enhanced Letterhead.
Classic Template
Lightning Email Template
Adding Multilingual Email Template Support
SendBetterEmail provides multi-lingual support within the same flow by allowing a set of related email templates to be created in different languages. In the flow, specify the desired language. To make this work, the names of the email templates must follow some rules:
Each language localization has its own template with all localizations sharing a common EmailTemplate.Name.
To differentiate the localizations, add the following text to the EmailTemplate’s Description fieldt: โLanguage=โen_USโโ (or whatever corresponding to your organization localizations).
This is a complex, advanced functionality that should be used only when needed. You are much better off using the standard functionality unless you have bulk requests that cannot be satisfied with a SendBetterEmail request.
SendBetterEmail can be used to send bulk email using collections of; 1) Single Email Requests, 2) Mass Email Requests, or 3) a blend of both. Single and Mass email requests can each be individually bulkified (up to the limit for each type), or a Single Email request can be individually customized for each email.
This simplified example just shows how to create a collection of requests using the “Send Better Email Bulk Request Setup”. A collection of requests can be created and then sent as a collection (up to 10 requests of each type [single, mass] in a collection), where each request is:
a single customized email
a single email using address collections and/or target (recipient) id collection
a mass email a using target (recipient) id collection
Bulk email with sendBetterEmail is a three step process:
Create a collection of requests using the “Send Better Email Bulk Request Setup” Flow Action with the Custom Parameter Editor which will create a SendBetterEmailRequest which can be added to the collection of SendBetterEmailRequest
Use the “Send Better Email Bulk” Flow Action to send the collection of SendBetterEmailRequests created in step 1
Loop through the collection of SendBetterEmailResponse returned from the “Send Better Email Bulk” Flow Action for status.
All requests are (of course) subject to organization limits which can be found in the Apex Developer Guide, Execution Governors and Limits, Section on Email Limits – Outbound Email: Limits for Single and Mass Email Sent Using Apex. If templates and/or collections of recipients are used, single email message types are limited to 150 total addresses per request and mass email message types are limited bye the edition. For professional Edition of Salesforce, thatโs 250 emails in a single call, or if you are running Enterprise Edition, 500. For Unlimited Edition, you can send 1,000 emails in a single call.
Operational Considerations
This action makes use of the standard Salesforce email infrastructure, the same service that you use when you send a single email directly from a lightning experience page or a classic case feed. As such, any emails you send will be included in your usage, so be aware of the limits and guidelines. (Developer note: this action makes use of the Apex Messaging service API’s.)
This action does not use or involve Email Alerts, which are used in Workflow Rules and exist in Flow as separate actions you can drag into your flow. Be mindful of this so you don’t accidentally confuse the Email Alerts, the Email Templates, and the Flow Text Templates.
Mass Email – Send an email using MassEmail messaging
Bulk Email – Send bulk email using request collections
Troubleshooting
Problem Statement: Apex Test Class SendBetterEmailTest fails for test cases t001 with error message System.AssertException: Assertion Failed: emailDeliverabilityEnabled and capacity exceeded: Expected: true, Actual: false Stack Trace: Class.SendBetterEmailTest.t001_canSendEmail: line 240, column 1 This happens even when the email deliverability is ‘All Emails’ In the orgResolution: Turn Off the Email Bounce Management in the org as the email address utilized in test classes are invalid and due to bounce management requires to be validated. If bounce management cannot be turned off then change the email address utilized in the test classes to one of the valid email address.
Credits
MVP Jeremiah Dohn pioneered this space several years back with his well received HTML Email Flow action. The version here is similar and adds a several of additional capabilities.
Jack Pond added a great deal of functionality and a custom property editor.
2.1.6 Unlocked 08/08/2021 Bugfix release. Fixes several checkbox issues, sending multiple versions of attachments, and various save as activity and tasks issues. #702, #831, #785, #823#829, #581. Make sure you update Flow Actions Base Pack and the Flow Screen Components Base Pack before applying this update.
Includes two new features, Treat Target Object As Recipient and In Reply To and fixes various bugs including attachment naming and using templates without description information.
USAGE NOTE: After Version 2.0.4, Use Salesforce Signature defaults to false. Previously it defaulted to true. That means that if you did not set it at all in your previous use of Send Better Email, your emails added your Salesforce Signature but now will stop doing that unless you explicitly set this to true
2.0.4 Unlocked 11-29. Bug fixes for lwclogger conflict and broken attachments
2.0.1 Unlocked sendBetterEmail The first full Custom Property Editor version that supports both singleEmail and massEmail and has several fixes.
1.33.2 Unmanaged sendHTMLEmail (with Flow Examples/Tests) – Major upgrade that includes several enhancements and bug fixes. Parameters are now selected using a Custom Property Editor. Additionally, mass email messaging has been included.
1.33.1 Unmanaged sendHTMLEmail (with Flow Examples/Tests) – Minor update Addresses issues #308 and #316 to fill in Task Comments and Recipients and improved documentation.