Invocable methods used with Flow allow you to launch something in an admin friendly format that uses the massive power of Apex. For example, you have an intake screen that collects answers to a few questions, then you use Apex to loop through many related records dispersing those answers in places hard to reach from Flow.
Creating an invocable method in a nutshell: First you write an apex class with @invocable method (label and description) and whatever code you want the apex to do (easy, right?) Then make your Flow including your input and output variables. Then add an Apex action in Flow to send/receive those variables.
Here are some things I learned about sending data between Flow and Apex.
Record Collection Variable
List containing 1 sObject record
Record (single) variable
List of Lists of sObject
Record Collection Variable
This is NOT an exhaustive list at all. I didn’t try sending a record variable (not just the ID from Flow), but I assume that will work. There are also generic sObjects that are pretty special, but I didn’t try.
“Here is the use case: sending a family of a deceased relative one letter with all the names of people who have donated in memoriam. So, one letter to the family for many people who gave. Client is a large hospice so this is happening weekly. Open to different options — apps? exports & merge? other? Thanks!”
Broad use case: Use the new Collection Sort feature in Flow to find a specific number of records that meet your criteria, and sort them with one or more criteria (criterion?)
Example use cases: I want my top 3 open opps to have a giant dollar sign image on them or I want to automatically nudge/shame the five users who logged in least last month or I want to focus a campaign on my most active volunteers in the summer.
Our specific case: I want to look at a contact record in Nonprofit Success Pack and see immediately that they are one of my top ten donors.
This post is building on the work of the super-smarty Narender Singh aka ForcePanda aka @Nads_P07. With Spring ’21 rich text emails, you can now send tables with lists of child objects.
I followed his tutorial and built two Flow’s specifically using Nonprofit Success Pack (NPSP) objects. The first one is a list of payments and the second is a list of completed volunteer activities. I’ll blog about the second one later. Also on the to-do list is to make one that lists all the gifts received in memory or in tribute to someone else.
JULY 30, 2021 UPDATE: This version is now outdated! Please go here for the latest.
Unsubscribe Link 2.2 (OUTDATED)
Allow Recipients to Unsubscribe From All Email Sent via Salesforce
When the recipient clicks to unsubscribe, a flow will look for all contacts and leads who have this email in the Email field and mark them “Email Opt Out.” The email address owner will receive one confirmation email immediately. A custom object tracks when someone unsubscribes to allow you to report on it.
See How It Works
UPDATE: 1/28/21 I realized how to send the confirmation email from someone other than “Site Guest User.” More in this post.
I built this really great app to allow email recipients to unsubscribe from all emails sent through Salesforce, but it hasn’t been exactly easy to set up or use. Introducing the first upgrade which makes it much more user friendly!
With the upgrade, your Salesforce users can now pull a merge field into their Lightning and Classic email templates to include the Unsubscribe Link. Bam. No more having to modify and clone confusing email templates.
I’m back from maternity leave and holy SMOKES (get it? The west coast is on fire): an update to Flow in Summer ’20 totally broke the Unsubscribe Link App. It’s okay, though. It’s fixed now and this Flow improvement is worth it.
It’s now much simpler to expose a Flow to folks who aren’t logged into Salesforce. They can click a link which launches a Flow that modifies, deletes and creates all sorts of records! (Be careful!)
All you have to do now is save your flow as System Context without Sharing–Access All Data. This eliminates the need to give a Site Guest User permission, adjust your sharing settings, and create sharing rules.
So my example is the Unsubscribe Link. You send an email through Salesforce with this link. Your recipient clicks on it and that launches the Flow which will update their contact and lead records with Email Opt Out. It’s pretty sweet.