function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ken KoellnerKen Koellner 

Can't send Workflow Emal Alert to Parent email field, any workaround???

I want to send a workflow email alert to the address in an email field on a record that is the parent of the record being processed.


There doesn't appear to be a way to do that.  I can reference parent fields all I want in the Formula that qualifies the Workflow.  But in the Email alert, when I select "Email Field", I only get Email fields in the actual record, not parent fields available.

 

The only work around I have found for this restriction is to write Apex code to copy the email field value of the parent into an email field on the child record.  That is really a pain.  It's never good to copy stuff around.  To keep in sync, both objects need update triggers that cascade update other records.

 

If a formula field could be of type email, I could define a formula field on the child that references the parent field.  But formula fields can't be type email.  (I added an Idea to allow that. feel free to vote up https://success.salesforce.com/ideaView?id=08730000000kwYAAAY.)

 

Without that feature I can't think of any way to do using definition features, only Apex.

 

Anyone have any ideas for another workaround for this issue?

 

Ken KoellnerKen Koellner

I think I may have found a work-around that's more elegant then writing a bunch of Apex code.  It involves a custom email field on the child record and a workflow to set it but the workflow sets it right before the email is sent.

 

  1. Define email field on child record.
  2. Define one workflow on child record with two actions.
  3. First action copies value of parent email address to child custom email field.
  4. Second action sends email to child custom email field.

I haven't run this yet but I don't see why it shouldn't work.  Better not to have to copy stuff around but doing it workflow is a heck of a lot less work then written a bunch of Apex trigger code to keep things in sync.  Since the email field is only needed to send the workflow email, not populating it until right before the email is sent and always populating it when the email is sent is an acceptable solution.

 

Now I just have to test and hope it work.

 

-Ken

 

 

Chris Tufts 3Chris Tufts 3
it does require a little bit of thought on order of operations but I successfully got this working in a process builder. 
The easiest most non-efficient way of doing it is as follows...

1 add email address field as suggested above to child record
2 create a email alert that uses this new field as the send to
3 add a process builder flow that can be run multiple times on a record
4 add a step that checks if the email field created above is null (and any other criteria for sending the email) then update the record with the email address and shoot off the email alert.
5 add a step to check if the email on the parent record has changed, if so update it (this is where the run multiple times comes in...)
6 check for criteria to send the email if that passes fire the email alert.

I only caution the above method as it could fire inconsistently due to the order in which the workflows actions might fire, which I don't believe you can specify as you can in the process builder.

good luck! 
SFDC DronaSFDC Drona
Hey Ken,

To solve this issue I have added some hack, please try out following solution, this will work perfectly without any apex code or multiple workflows:

http://www.sfdcdrona.com/2017/10/email-alert-to-parent-objects-email.html


User-added image

Thanks
jalexanderjalexander
SFDC Drona, your hack above is the best solution I've seen!
  • I was just about to try multiple formula fields, process builder APEX, workflows, etc..
  • This hack works out of the box in Lightning
  • Very simple to implement