We are trying to do something that seems pretty simple – when an opportunity changes stages we want to automatically send an email to a subset of related contacts. That subset is any related contact that has the Role of "Partner". According to SFDC Admin Assist, the email notification feature in Salesforce can only email ALL the related contacts, and cannot filter for specific roles. However, they did say that a Flow would solve the issue (but creating the Flow itself is out of scope for them).
Example of what we need:
- Situation: Opportunity A has 3 related contacts – Jill (CEO), John (COO), Sam (Partner), and Alex (Partner)
- Trigger: Opportunity A moves from Stage 1 to Stage 2
- Result: We want to automatically send an email to Sam and Alex but not Jill or John
Can anyone help get us on the right path?
You can achieve this by using a combination of Process Builder and an Autolaunched Flow.
If the Opportunity Stage is changed, call the Autolaunched Flow from the Process Builder passing the Opportunity Id. (Declare Opportunity_Id as an input variable in flow).
In flow, query for Contacts related to the Opportunity and having Role as 'Partner' (I have created a lookup on Contact to Opportunity and a custom field 'Role' on Contact. You can change these based on your requirements.)
Loop through the queried Contacts, add their email addresses in a flow text collection variable.
Add the Core Action element Send Email and pass the Email Addresses collection variable.