I need to set an email value on a custom object (Missed_Day__c.Supervisor_Email__c) where the email is coming from an indirectly related custom object. Then I need to send an email to Supervisor_email__c. In Process Builder, I would just set the value then schedule the next step to (almost immediately) send the email. That's got to be possible in Flow but I can't see how to do it. Here are additional details:
- When Missed_Day__c is created, send an email to the Supervisor
- The Supervisor's email is located two objects away:
Missed_Day__c / Employment__c (lookup) / Supervisor__c (lookup to Contact) / Email
- I have an email field on the Missed_Day object called Supervisor_Email__c
- This email field is referenced in the Email Alert, as are other fields on the Missed_Day object
- I can populate Supervisor_Email easily enough, but then I need to commit it to the database before calling the Email Alert.
How do I do that?
Forum Ambassador Piyusha Pilania (Implementology)
@Ken Tallman To achieve the described requirement using Flow, follow these steps:
- Use a Record-Triggered Flow that starts when a `Missed_Day__c` record is created.
- Start by using the `Get Records` element to fetch the related `Employment__c` record using the lookup relationship from `Missed_Day__c`.
- Use another `Get Records` element to fetch the `Supervisor__c` (Contact) record using the lookup from the `Employment__c` record. This will provide the Supervisor's Email.
- Use an `Assignment` element to assign the Supervisor's email (fetched in the previous step) to `Missed_Day__c.Supervisor_Email__c`.
- Use an `Update Records` element to save the updated `Missed_Day__c` record with the Supervisor's Email. This ensures that the `Supervisor_Email__c` field is committed to the database.
- Now, use the `Send Email` element (available in Summer '21 release and later) to send the email alert. Use the `Missed_Day__c.Supervisor_Email__c` as the recipient. If you're on an older Salesforce version, create an Email Alert in the Setup area and use the `Action` element in Flow to send the email alert.
Remember, flows run in the order of their elements. By setting up the elements in the sequence described above, you ensure that the email address is committed to the database before the email alert is triggered.
Also, Salesforce will stop all support for process builder soon. So please migrate all your workflow rules and process builder automations to flows now.