Send email to contact role on Close Won Opportunities? - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Stephanie GelinasStephanie Gelinas 

Send email to contact role on Close Won Opportunities?

Hi, I want to create a Workflow that sends an Email Alert to a contact upon close won of an opportunity.

The problem is that the contact is not available in the list of Recipient type... How can I choose the Contact with role "Project" associated with it.

User-added image
 
Deepak AnandDeepak Anand
I wish it was that easy :-)

Opportunity Contact Role is a child object to Opportunity. This means that for an Opportunity, there may or may not be more than one Contact at a time. So you will not be able to select them the way described. Salesforce wouldn't know which Contact to pick up since there could be more than one.

So in order to accomplish this, you will have to do some legwork.
  1. Create a Process on the Opportunity that looks for changes in the Stage field ( Stage = Closed Won ).
  2. Then this Process would fire a Flow. Why a Flow now? Keep reading.
  3. The Flows have this powerful element called Loop. This can be utilized to loop or in other words, iterate through all the child Contact Roles on the Opportunity to pick the one that has the Role = Project.
  4. Then we need to use a Get Record node inside of the same Flow to query the Contact's Email.
  5. You will then create a new Email Field on the Opportunity. Call it - Project Contact Email.
  6. The Flow would update the Opportunity with the Contact's (Project) Email.
  7. Then you can set up another Process or Workflow Rule that looks for changes in this Email Field (Project Contact Email) and then spawn an Email Alert.
I know that's a lot and but that's the closest we can do today.

In the Winter 20 Release, they say that the Opportunity Contact Role object was made a First Class Object (https://releasenotes.docs.salesforce.com/en-us/winter20/release-notes/rn_sales_opportunity_contact_roles_customize.htm) but I still don't have even the slightest clue why we cannot set up Workflows / Process on this object. If that was the case, we could reduce the complexity a bit.
Stephanie GelinasStephanie Gelinas

Thanks Deepak for the detailled answer, I trully appreciate it. I'm affraid I won't be able to complete this on my own without a step by step. Do you know of a reference that I could follow?

I found this ressource but screenshots are outdated and can't seem to find the equivalent in Lightning.
https://succeedwithsalesforce.com/using-process-builder-and-flows-to-send-email-to-a-primary-contact-on-an-opportunity/

I you could point me to something similar I can use that would be great!

Thanks

Stephanie