Use Case: Automate Emails with Schedule-Triggered Flow
If you also have the need to send out batch emails under specific criteria or at specific dates, you should definitely consider Schedule-Triggered Flow. Schedule-Triggered Flow can also run for a batch of records if the object and the filter conditions are specified. You build the flow as if it is for one record, but it will run for all the records that match the criteria (So you don’t have to think about collections. Isn’t this nice?!). Let’s dive into how to set this up!
* Big thanks to Parker for sending in the case!
Lulu Mobile uses the standard Account object to track phone subscriptions. They have a field called “Expiration Date” which tracks when the subscription ends. When it reaches 90 days before the expiration date, they want to send a reminder to the customers. They will send it to the primary contact specified on each account.
(Assumption: One account will only have one primary contact)
We will use the Schedule-Triggered flow and let it run daily. Every day we check how many accounts have reached 90 days before the expiration date. Then we send emails to their primary contact.
Since we cannot use formula in the Choose Object and Filter Conditions, we will use a workaround suggested by Salesforce.
Scheduled Action v.s. Schedule-Triggered Flow
“If we schedule the flow to run daily, wouldn’t it exhaust the capacity?” is the question I have about schedule-triggered flow. Because alternatively, we can also schedule actions (ex. in Process Builder) when the expiration date is updated. I imagine this is easier on the workload, as the system evaluates each account only once. However, it might be more error-prone as those actions would need to stay in the backlog for a long time (it is 90 days in this example, but could be 2-3 years based on your scenarios). Also, if we specify the conditions properly, the schedule-triggered flow might not be as overloading as we imagine. Unfortunately, I can’t find any accurate comparison on the two, so I would suggest “use schedule-triggered flow when it’s a separate set of actions and using scheduled actions when you can add it to some nodes in your existing processes or flows.”
Schedule-Triggered Flow | Get Records | Action |
Does the solution solve your problem? If not, write us what your problem is and we will build the flow for you!
Hello,
Thanks for this, it was very helpful! I did come across an issue though: I implemented this in a way so that the account owners get notified that their customers license will expire. But if an owner owns multiple accounts with customers whose licenses expire, the user will only get one email notification instead of one per expiring license. Is there a way to make it that one user can receive multiple emails?
Thanks,
Thanks Angesol. If I am not wrong, the license is its own object? If you are looking to send one email per expiring license, I will recommend building the schedule-triggered flow on the license object instead. Then you will have one email per license, instead of one email per account. Hope this helps, otherwise let me know if I am missing any details!
Hello Melody, Thanks for the reply. I did build it directly on the License object, with 2 conditions, that the expiry date i soon, and that the license is active. Then I got the account ID linked to the license, and then I email the owner of the account that a license they’re responsible for will expire.
When I did the tests, I made two licenses fulfill the conditions, and both licenses were linked to the same account, but I only get one email from one license. If I de-activate one of the two, I get the correct email, but if they’re both active I only get one email.
Hmm that’s strange. I just tested the solution again and it should work on sending multiple emails to the same person. Did you do the test from the debug mode, or did you activate it and wait for the schedule job to finish? If you did it in the debug, the system can only debug on the “first record” it finds – so there will always be only one email sent. If you test the flow after activating it, then both emails should be sent. Let me know what’s the case and if we need to do a deeper dive.
Ahh great, thanks for the reply! I was just using the debug mode, that is why only one email was sent! Now that it’s activated it worked great.
Thank-you for this very simple solution 🙂
Have a nice day
Nice to hear that Angesol! No problem at all and thanks for your nice words. Have a great day you too!
Hello! With Angesol’s example, is it possible to send one email that contains the license information for both records, instead of 1 email per license?
Hi Chelsea, yes it is possible. Then you will start your flow from the Account object again (Since you are looking for one email per Account, if I understand correctly?)
If you just want to include the “Count” of the total licenses, you just need to get all licenses and create a variable to store the count of the collection. However if you want to show a table of all the licenses, you would need to create some custom variables to embed that table. Here is one post from forcePanda that’s really good! Hope this will be helpful:
https://forcepanda.wordpress.com/2021/03/23/how-to-send-table-in-emails-via-flow/
Very cool! I didn’t even know that was possible. Thank you!
No problem at all:)
Hi,
Could you help me… I have similar scenario when custom object (procedure) criteria met i need to send notification to procedure owner . But even owner has multiple procedures he needs to recieve only one notification..please help me as im getting one notification for each record.
This is helpful! Only snag I’m running into is if the criteria changes after the fact, the scheduled job isn’t cancelled. For example, I want to send a daily email 7 days before a due date so long as the record is considered “open”. If the status changes from “open” to anything else, the emails should be cancelled; however, the scheduled job continues to queue up the daily email.
Thanks Kev! Hmm that is strange. If you use a schedule path, when the conditions are no longer met before the resume date, the whole schedule actions should be cancelled instead. (We can check this in Time-Based Workflow)
If you like, you can send me your current flow design and we can trouble shoot together!
Hi there, I was trying to create a flow that would send an email the day before an assignment expires. (I created a checkbox formula field that shows true for this) It’s scheduled to run daily. Only thing I’m not sure is if it is looking at all assignments. I set up a test record that should trigger it, but debug shows no email output.
Hi Samantha, the debug mode in flow will only run on the first record that matches the criteria. If you want to see how many records enter the scheduled-triggered flow, you will have to set up a debug log. So if the debug mode shows your flow runs correctly and now you want to see if it fires on all records, I suggest you can activate the flow in the sandbox and set up multiple test records to see if they all work (by checking debug logs)
Hey there,
Just want to flag that using the new-ish Enhanced Email template builder in LEX will NOT WORK in this situation.
Why?
Because email templates in Lightning Experience use Handlebars Merge Language (HML), and flow email alert actions only work with email templates using the old SML (Salesforce Merge Language)
SML = merge fields have one curly brace {, or an exclamation mark !
example: {{{Recipient.FirstName}}}
HML = merge fields with three curly braces {{{
example: {!Lead.FirstName}