[SalesForce] Email Alerts to Customers using Work Flow processes

Creating a work flow email alert. Would like to send out to customers email found in opportunity under contact roles. Currently, the only options are to select from drop down recipient type. Is there a way to do this by selecting "role" or would custom coding need to be written?

Best Answer

The Opportunity Contacts aren't available for Workflow Rules, BUT you could create a flow send an email to each contact that is listed in the roles and have it record as an activity on the Opp (Email Alerts do not have tracking visibility). If that might work for you, depending on the criteria for the email to be sent I would try the following:

Create a flow with the following:

  • sObject variable (var) for the Opporutnity (ref as: thisOpp) sObject
  • Collection var for the Opportunity Contact Role records OppContacts
  • sObject var for the Contact record we are emailing Contact2Email
  • sObject Collection for the emailed contacts EmailedContacts Text
  • Template for the EMail Body (this can have formatting), EmailBody
  • Text Template for Email Subject, EmailSubject
  • Text Template for Fault Email, FaultEmail
  • Text Template for Fault Subject, FaultSubject

Creating the flow

  1. Create a Loop Record to lookup the opportunity that has the Contacts associated with it that we need to contact. I will reference this variable as thisOpp. On the Record Lookup, select the field values of the Opp that you will want to reference in your flow or templates, at a minimum you need the Id
  2. Now lookup the OpportunityContactRole record where the Opp Id = thisOpp and add them to the OppContacts sObject Colleciton with the OppId, ContactId, and any fields necessary
  3. Use the decision element to decide whether or not there are OppContacts in our collection
  4. If there are, go to a Loop, where you will be looping through the OppContacts to create a Contact2Email sObject
  5. Now lookup the contacts that have the Id = the Contact2Email's ContactId
  6. When emailing a collection, only 5 people can be emailed at a time. Now seeing as there is no limit on the # of Contact roles I would use the Send Email here, emailingh individual contacts using "Send Email". Use the text template EMailBody for the body and EmailSubject for the Subject
  7. Add an Assignment element to assign the contact that was in the email to a Collection called EmailedContact
  8. Then connect back to the Loop to complete the circle and loop through & email the other records
  9. Before saving and exiting your flow, make sure you create a "Send Email" and connect all of your lookup elements to it with the text templates FaultEmail and FaultSubject so if a fault occurs, you are notified

Create Process

  • In setup under workflow rules go to process Start the Process on the opp to only go through the process 1x
  • Set your criteria for what on an Opp qualifies for the email send
  • For your action, launch the flow you just made

and there you go, although I have not had the chance to test, this might at least get you started on options to email the Opportunity Contact Role Contacts with workflow. I made a mockup for you in my dev org to give you a visual of my idea. Flow ScreenShot

Related Topic