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
Ricki ReayRicki Reay 

HELP: Auto-populating "To" field on Email action form to comply with Email Tracking?

Hi all,

I am trying to create a custom action on the Opportunity object which populates the "To" field (API: ToAddress) on the email form like it does on the Lead and Contact/Person Account records. I want the field to auto-populate with the Person Account if the opportunity is linked to a Person Account (i.e. IsPerson = TRUE) and auto-populate with a custom field Company_Email__c if the opportunity is linked to a Business Account (i.e. IsPerson = FALSE). 

In order to have email tracking working, one of the requirements is that the To field links to a Contact, Person Account or Lead in Salesforce. So I can't just pre-populate the field with the email address on the Person Account - as this would not be linked as per Salesforce's email tracking requirements. I need this field to pre-populate so that it links to the actual record in SF. I have tried pre-populating with ID for this field, but have had no luck. Here is the formula I was attempting to use for this "To" lookup field:

if( Opportunity.Account.IsPersonAccount = TRUE,  Opportunity.Account.PersonContactID, Opportunity.Account.Company_Email__c)

And this is the result: 
User-added image
Whereas, I want it to do this:
User-added image

Appreciate any and all help on this.

Thanks,

Ricki
Best Answer chosen by Ricki Reay
AbhishekAbhishek (Salesforce Developers) 
Hi Ricki,

Try the suggestions as mentioned in the below blog,

https://success.salesforce.com/answers?id=9063A000000e9ogQAA

I hope it will help you.
 

All Answers

AbhishekAbhishek (Salesforce Developers) 
Hi Ricki,

Try the suggestions as mentioned in the below blog,

https://success.salesforce.com/answers?id=9063A000000e9ogQAA

I hope it will help you.
 
This was selected as the best answer
Ricki ReayRicki Reay
Hi Abhisek,

Thank you so much for sharing that link. I got it working using the JUNCTIONIDLIST function and "To Recipients" field, instead of the "To" field.

Thanks again - I very much appreciate it!

Ricki
 
Mandip Chana 10Mandip Chana 10
Hi Ricki,

Could you detail your solution please? I have tried using the JUNCTIONIDLIST function in both the "To" and "To Recipients" fields but no luck.

I am trying to populate these fields with the Contact Role on the Opportunity
Samy CoolsSamy Cools
Hi all,

I encountered the same issue and was also able to solve it using the 'To Recipients' field and the JUNCTIONIDLIST function too. 

After creating the custom email action, you indeed need to specy a predifined field value. Choose the 'To Recipients' field (not the 'To' field!) and construct your formula using the JUNCTIONIDLIST function. My use case was to auto populate the to field with the person account linked to the custom object I'm sending the email from, so my formula looked like this:

JUNCTIONIDLIST(My_Custom_Object__c.Custom_Relationship_Name__r.PersonContactId).

This help article givs some more details too: https://help.salesforce.com/s/articleView?id=sf.send_email_action_predefined_fields.htm&type=5

Hope this helps!