+ Start a Discussion
Sunil Damle 7Sunil Damle 7 

Choose email alerts dynamically or using SOQL Query

 I have a requirement to send an email to a team of co-ordinators for which I used the process builder. The process builder checks the type of event and then process would go to a appropriate action branch and an email alert will be sent. As you know, email alerts are associated with Recepients so all I need to do is check the type of event and perform an action of sending an email alert.
We have different set Co-ordinators for each event type.

But as design best practice, this what I want to do -
1. If we add a new event type 'XYZ'(this would be data setup) then I would create a email alert with same name 'XYZ' (again, just data setup, no configuration change)
2. My logic would then see the event type is XYZ so query for the email alert with the same name and would send the email

This way, if any new event type is added in future, I dont need to chagne the process or any logic.

But my problem is that, I dont seems to have a way to query for eMail alert. Has anyone impemented this? Or any other way you can suggest(even using Apex) which will meet the purpose of not changing the code/logic/process for adding a new event type and new email alert.