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
SquashcookieSquashcookie 

Send Email Alert to a parent's parent object

Hi Guys

I have a requirement to send an Email Alert to a Contact record that is the Parent's parent of a custom Object.

eg.

Contact > ObjectA > Object B

 

I have a field at ObjectB that I'm using to determine when to send the email, and I want it sent to ObjectB.ObjectA.Contact.email_address
However, there doesn't appear to be a way to use any of these lookup values to find the Contact's email address.

 

Has anyone come across this and found a solution?
In a normal database, it would be a pretty simple join to traverse up the tables.

 

thanks
Nick

 

 

Srikant JoshiSrikant Joshi

Hi Nick,

 

Yeah we had come across a similiar situation.

 

We had used trigger on Object B to fetch the email of the Contact onto one of the hidden fields in Object B.

 

Formula couldn't be used since 'email in Formula' is not supported.

 

Once you obtain the value in hidden field of Object B, then use it in Workflow to send emails.

 

Srikant

SabrentSabrent

I have had to do exactly the same as you want to do and I achieved this with a workflow,

On ObjectB__c i created a field called Contact_Email__c (Datetype: Email)
and populated this field via workflow field update.(This is because a formula cannot populate an email field, and the email template requires an email field to send mail to)

Workflow Field Update Detail:

Name: Populate Contact Email         
Unique Name:    populatecontactemail         
Description:    
Object:    ObjectB__C         
Field to Update    ObjectB__c: Contact_Email__c
Field Data Type: Email
Re-evaluate Workflow Rules after Field Change:    
Formula Value:    ObjectA__r.Contact__r.Email  

If you are comfortable writing triggers/ test class, i would suggest go the trigger way as suggested by @Srikant in the previous post.

Hope this helps.

SquashcookieSquashcookie

Hi Guys

 

Thanks for the advice.

This is what I was thinking, however I was hoping there would be a better way.

 

rov, why do you say that using the Trigger would be a better approach?

 

From what I can tell, they both acheive the same thing.

 

thanks for your input.

SabrentSabrent

You are right both achieve the same thing. Workflows are quick, easy to maintain and involves no programming error, no test class (sigh!!!). However, if order of execution is of concern, it is better to use triggers as they offer more flexibility. (triggers fire before workflow). I say triggers are better, from personal experience, but again, I would say, do what is easier and causes you less grief.